1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34: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>
(cherry picked from commit eeb60574b6)
This commit is contained in:
Stefan Metzmacher 2024-06-18 19:02:05 +02:00 committed by Jule Anger
parent 46ebf66fe9
commit 212b014679

View File

@ -227,6 +227,8 @@ static void torture_creds_krb5_state(void **state)
TALLOC_CTX *mem_ctx = *state;
struct cli_credentials *creds = NULL;
struct loadparm_context *lp_ctx = NULL;
enum credentials_obtained kerberos_state_obtained;
enum credentials_use_kerberos kerberos_state;
bool ok;
lp_ctx = loadparm_init_global(true);
@ -234,18 +236,27 @@ static void torture_creds_krb5_state(void **state)
creds = cli_credentials_init(mem_ctx);
assert_non_null(creds);
assert_int_equal(creds->kerberos_state_obtained, CRED_UNINITIALISED);
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_DESIRED);
kerberos_state_obtained =
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);
assert_true(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SMB_CONF);
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_DESIRED);
kerberos_state_obtained =
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);
assert_true(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SMB_CONF);
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_DESIRED);
kerberos_state_obtained =
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_non_null(creds->ccache);
@ -253,15 +264,21 @@ static void torture_creds_krb5_state(void **state)
CRED_USE_KERBEROS_REQUIRED,
CRED_SPECIFIED);
assert_true(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SPECIFIED);
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_REQUIRED);
kerberos_state_obtained =
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,
CRED_USE_KERBEROS_DISABLED,
CRED_SMB_CONF);
assert_false(ok);
assert_int_equal(creds->kerberos_state_obtained, CRED_SPECIFIED);
assert_int_equal(creds->kerberos_state, CRED_USE_KERBEROS_REQUIRED);
kerberos_state_obtained =
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);
}