tests/qtest/migration: Add a NULL parameters test for TLS
Make sure the TLS options handling is working correctly with a NULL parameter. This is relevant due to the usage of StrOrNull for the tls-creds, tls-authz and tls-hostname options. With this, all manners of passing TLS options are somehow covered by the tests, we should not need to do manual testing when touching TLS options code. Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20251215220041.12657-5-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
@@ -458,6 +458,15 @@ void migrate_set_parameter_strv(QTestState *who, const char *parameter,
|
||||
qtest_qmp_assert_success(who, command, parameter);
|
||||
}
|
||||
|
||||
void migrate_set_parameter_null(QTestState *who, const char *parameter)
|
||||
{
|
||||
qtest_qmp_assert_success(who,
|
||||
"{ 'execute': 'migrate-set-parameters',"
|
||||
"'arguments': { %s: null } }",
|
||||
parameter);
|
||||
migrate_check_parameter_str(who, parameter, "");
|
||||
}
|
||||
|
||||
static long long migrate_get_parameter_bool(QTestState *who,
|
||||
const char *parameter)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ void migrate_set_parameter_str(QTestState *who, const char *parameter,
|
||||
const char *value);
|
||||
void migrate_set_parameter_strv(QTestState *who, const char *parameter,
|
||||
char **strv);
|
||||
void migrate_set_parameter_null(QTestState *who, const char *parameter);
|
||||
void migrate_set_parameter_bool(QTestState *who, const char *parameter,
|
||||
int value);
|
||||
void migrate_ensure_non_converge(QTestState *who);
|
||||
|
||||
@@ -507,6 +507,57 @@ static void test_precopy_tcp_tls_psk_mismatch(void)
|
||||
test_precopy_common(&args);
|
||||
}
|
||||
|
||||
static void *migrate_hook_start_no_tls(QTestState *from, QTestState *to)
|
||||
{
|
||||
struct TestMigrateTLSPSKData *data =
|
||||
g_new0(struct TestMigrateTLSPSKData, 1);
|
||||
|
||||
migrate_set_parameter_null(from, "tls-creds");
|
||||
migrate_set_parameter_null(to, "tls-creds");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void test_precopy_tcp_no_tls(void)
|
||||
{
|
||||
MigrateCommon args = {
|
||||
.listen_uri = "tcp:127.0.0.1:0",
|
||||
.start_hook = migrate_hook_start_no_tls,
|
||||
.end_hook = migrate_hook_end_tls_psk,
|
||||
};
|
||||
|
||||
test_precopy_common(&args);
|
||||
}
|
||||
|
||||
static void *
|
||||
migrate_hook_start_tls_x509_no_host(QTestState *from, QTestState *to)
|
||||
{
|
||||
TestMigrateTLSX509 args = {
|
||||
.verifyclient = true,
|
||||
.clientcert = true,
|
||||
.authzclient = true,
|
||||
};
|
||||
TestMigrateTLSX509Data *data = migrate_hook_start_tls_x509_common(from, to,
|
||||
&args);
|
||||
migrate_set_parameter_null(from, "tls-hostname");
|
||||
migrate_set_parameter_null(to, "tls-hostname");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void test_precopy_tcp_tls_no_hostname(void)
|
||||
{
|
||||
MigrateCommon args = {
|
||||
.listen_uri = "tcp:127.0.0.1:0",
|
||||
.start_hook = migrate_hook_start_tls_x509_no_host,
|
||||
.end_hook = migrate_hook_end_tls_x509,
|
||||
.result = MIG_TEST_FAIL_DEST_QUIT_ERR,
|
||||
.start.hide_stderr = true,
|
||||
};
|
||||
|
||||
test_precopy_common(&args);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TASN1
|
||||
static void test_precopy_tcp_tls_x509_default_host(void)
|
||||
{
|
||||
@@ -799,6 +850,11 @@ void migration_test_add_tls(MigrationTestEnv *env)
|
||||
return;
|
||||
}
|
||||
|
||||
migration_test_add("/migration/precopy/tcp/no-tls",
|
||||
test_precopy_tcp_no_tls);
|
||||
migration_test_add("/migration/precopy/tcp/tls/no-hostname",
|
||||
test_precopy_tcp_tls_no_hostname);
|
||||
|
||||
migration_test_add("/migration/precopy/unix/tls/psk",
|
||||
test_precopy_unix_tls_psk);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user