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>
This commit is contained in:
parent
c715ac5e49
commit
eeb60574b6
@ -234,6 +234,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);
|
||||
@ -241,18 +243,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);
|
||||
|
||||
@ -260,15 +271,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);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user