1 #include "clar_libgit2.h"
3 #include "git2/cred_helpers.h"
5 void test_network_cred__stock_userpass_validates_args(void)
7 git_cred_userpass_payload payload
= {0};
9 cl_git_fail(git_cred_userpass(NULL
, NULL
, NULL
, 0, NULL
));
11 payload
.username
= "user";
12 cl_git_fail(git_cred_userpass(NULL
, NULL
, NULL
, 0, &payload
));
14 payload
.username
= NULL
;
15 payload
.username
= "pass";
16 cl_git_fail(git_cred_userpass(NULL
, NULL
, NULL
, 0, &payload
));
19 void test_network_cred__stock_userpass_validates_that_method_is_allowed(void)
22 git_cred_userpass_payload payload
= {"user", "pass"};
24 cl_git_fail(git_cred_userpass(&cred
, NULL
, NULL
, 0, &payload
));
25 cl_git_pass(git_cred_userpass(&cred
, NULL
, NULL
, GIT_CREDTYPE_USERPASS_PLAINTEXT
, &payload
));
29 void test_network_cred__stock_userpass_properly_handles_username_in_url(void)
32 git_cred_userpass_plaintext
*plain
;
33 git_cred_userpass_payload payload
= {"alice", "password"};
35 cl_git_pass(git_cred_userpass(&cred
, NULL
, NULL
, GIT_CREDTYPE_USERPASS_PLAINTEXT
, &payload
));
36 plain
= (git_cred_userpass_plaintext
*)cred
;
37 cl_assert_equal_s(plain
->username
, "alice");
40 cl_git_pass(git_cred_userpass(&cred
, NULL
, "bob", GIT_CREDTYPE_USERPASS_PLAINTEXT
, &payload
));
41 plain
= (git_cred_userpass_plaintext
*)cred
;
42 cl_assert_equal_s(plain
->username
, "alice");
45 payload
.username
= NULL
;
46 cl_git_pass(git_cred_userpass(&cred
, NULL
, "bob", GIT_CREDTYPE_USERPASS_PLAINTEXT
, &payload
));
47 plain
= (git_cred_userpass_plaintext
*)cred
;
48 cl_assert_equal_s(plain
->username
, "bob");