1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

auth/credentials: add tests for cli_credentials_get_kerberos_state[_obtained]()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15666

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Stefan Metzmacher 2024-06-18 19:02:05 +02:00
parent c715ac5e49
commit eeb60574b6

View File

@ -234,6 +234,8 @@ static void torture_creds_krb5_state(void **state)
TALLOC_CTX *mem_ctx = *state; TALLOC_CTX *mem_ctx = *state;
struct cli_credentials *creds = NULL; struct cli_credentials *creds = NULL;
struct loadparm_context *lp_ctx = NULL; struct loadparm_context *lp_ctx = NULL;
enum credentials_obtained kerberos_state_obtained;
enum credentials_use_kerberos kerberos_state;
bool ok; bool ok;
lp_ctx = loadparm_init_global(true); lp_ctx = loadparm_init_global(true);
@ -241,18 +243,27 @@ static void torture_creds_krb5_state(void **state)
creds = cli_credentials_init(mem_ctx); creds = cli_credentials_init(mem_ctx);
assert_non_null(creds); assert_non_null(creds);
assert_int_equal(creds->kerberos_state_obtained, CRED_UNINITIALISED); kerberos_state_obtained =
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_DESIRED); cli_credentials_get_kerberos_state_obtained(creds);
kerberos_state = cli_credentials_get_kerberos_state(creds);
assert_int_equal(kerberos_state_obtained, CRED_UNINITIALISED);
assert_int_equal(kerberos_state, CRED_USE_KERBEROS_DESIRED);
ok = cli_credentials_set_conf(creds, lp_ctx); ok = cli_credentials_set_conf(creds, lp_ctx);
assert_true(ok); assert_true(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SMB_CONF); kerberos_state_obtained =
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_DESIRED); cli_credentials_get_kerberos_state_obtained(creds);
kerberos_state = cli_credentials_get_kerberos_state(creds);
assert_int_equal(kerberos_state_obtained, CRED_SMB_CONF);
assert_int_equal(kerberos_state, CRED_USE_KERBEROS_DESIRED);
ok = cli_credentials_guess(creds, lp_ctx); ok = cli_credentials_guess(creds, lp_ctx);
assert_true(ok); assert_true(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SMB_CONF); kerberos_state_obtained =
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_DESIRED); cli_credentials_get_kerberos_state_obtained(creds);
kerberos_state = cli_credentials_get_kerberos_state(creds);
assert_int_equal(kerberos_state_obtained, CRED_SMB_CONF);
assert_int_equal(kerberos_state, CRED_USE_KERBEROS_DESIRED);
assert_int_equal(creds->ccache_obtained, CRED_GUESS_FILE); assert_int_equal(creds->ccache_obtained, CRED_GUESS_FILE);
assert_non_null(creds->ccache); assert_non_null(creds->ccache);
@ -260,15 +271,21 @@ static void torture_creds_krb5_state(void **state)
CRED_USE_KERBEROS_REQUIRED, CRED_USE_KERBEROS_REQUIRED,
CRED_SPECIFIED); CRED_SPECIFIED);
assert_true(ok); assert_true(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SPECIFIED); kerberos_state_obtained =
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_REQUIRED); cli_credentials_get_kerberos_state_obtained(creds);
kerberos_state = cli_credentials_get_kerberos_state(creds);
assert_int_equal(kerberos_state_obtained, CRED_SPECIFIED);
assert_int_equal(kerberos_state, CRED_USE_KERBEROS_REQUIRED);
ok = cli_credentials_set_kerberos_state(creds, ok = cli_credentials_set_kerberos_state(creds,
CRED_USE_KERBEROS_DISABLED, CRED_USE_KERBEROS_DISABLED,
CRED_SMB_CONF); CRED_SMB_CONF);
assert_false(ok); assert_false(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SPECIFIED); kerberos_state_obtained =
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_REQUIRED); cli_credentials_get_kerberos_state_obtained(creds);
kerberos_state = cli_credentials_get_kerberos_state(creds);
assert_int_equal(kerberos_state_obtained, CRED_SPECIFIED);
assert_int_equal(kerberos_state, CRED_USE_KERBEROS_REQUIRED);
} }