]> git.proxmox.com Git - libgit2.git/blame - tests-clar/network/cred.c
Expose stock user/pass credential utility
[libgit2.git] / tests-clar / network / cred.c
CommitLineData
ffb02b16
BS
1#include "clar_libgit2.h"
2
3#include "git2/transport.h"
4
5void test_network_cred__stock_userpass_validates_args(void)
6{
7 git_cred_stock_userpass_plaintext_payload payload = {0};
8
9 cl_git_fail(git_cred_stock_userpass_plaintext(NULL, NULL, 0, NULL));
10
11 payload.username = "user";
12 cl_git_fail(git_cred_stock_userpass_plaintext(NULL, NULL, 0, &payload));
13
14 payload.username = NULL;
15 payload.username = "pass";
16 cl_git_fail(git_cred_stock_userpass_plaintext(NULL, NULL, 0, &payload));
17}
18
19void test_network_cred__stock_userpass_validates_that_method_is_allowed(void)
20{
21 git_cred *cred;
22 git_cred_stock_userpass_plaintext_payload payload = {"user", "pass"};
23
24 cl_git_fail(git_cred_stock_userpass_plaintext(&cred, NULL, 0, &payload));
25 cl_git_pass(git_cred_stock_userpass_plaintext(&cred, NULL, GIT_CREDTYPE_USERPASS_PLAINTEXT, &payload));
26 git__free(cred);
27}