2
#include "curl_config.h"
9
char password[PASSWORDSIZE];
12
static CURLcode unit_setup(void)
19
static void unit_stop(void)
26
static const char* filename1 = "log/netrc";
27
memcpy(filename, filename1, strlen(filename1));
30
* Test a non existent host in our netrc file.
32
result = Curl_parsenetrc("test.example.com", login, password, filename);
33
fail_unless(result == 1, "Host not found should return 1");
34
fail_unless(password[0] == 0, "password should not have been changed");
35
fail_unless(login[0] == 0, "login should not have been changed");
38
* Test a non existent login in our netrc file.
40
memcpy(login, "me", 2);
41
result = Curl_parsenetrc("example.com", login, password, filename);
42
fail_unless(result == 0, "Host should be found");
43
fail_unless(password[0] == 0, "password should not have been changed");
44
fail_unless(strncmp(login, "me", 2) == 0, "login should not have been changed");
47
* Test a non existent login and host in our netrc file.
49
memcpy(login, "me", 2);
50
result = Curl_parsenetrc("test.example.com", login, password, filename);
51
fail_unless(result == 1, "Host should be found");
52
fail_unless(password[0] == 0, "password should not have been changed");
53
fail_unless(strncmp(login, "me", 2) == 0, "login should not have been changed");
56
* Test a non existent login (substring of an existing one) in our
59
memcpy(login, "admi", 4);
60
result = Curl_parsenetrc("example.com", login, password, filename);
61
fail_unless(result == 0, "Host should be found");
62
fail_unless(password[0] == 0, "password should not have been changed");
63
fail_unless(strncmp(login, "admi", 4) == 0, "login should not have been changed");
66
* Test a non existent login (superstring of an existing one)
69
memcpy(login, "adminn", 6);
70
result = Curl_parsenetrc("example.com", login, password, filename);
71
fail_unless(result == 0, "Host should be found");
72
fail_unless(password[0] == 0, "password should not have been changed");
73
fail_unless(strncmp(login, "adminn", 6) == 0, "login should not have been changed");
76
* Test for the first existing host in our netrc file
80
result = Curl_parsenetrc("example.com", login, password, filename);
81
fail_unless(result == 0, "Host should have been found");
82
fail_unless(strncmp(password, "passwd", 6) == 0,
83
"password should be 'passwd'");
84
fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
87
* Test for the first existing host in our netrc file
91
result = Curl_parsenetrc("example.com", login, password, filename);
92
fail_unless(result == 0, "Host should have been found");
93
fail_unless(strncmp(password, "passwd", 6) == 0,
94
"password should be 'passwd'");
95
fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
98
* Test for the second existing host in our netrc file
103
result = Curl_parsenetrc("curl.example.com", login, password, filename);
104
fail_unless(result == 0, "Host should have been found");
105
fail_unless(strncmp(password, "none", 4) == 0,
106
"password should be 'none'");
107
fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
110
* Test for the second existing host in our netrc file
111
* with login[0] != 0.
114
result = Curl_parsenetrc("curl.example.com", login, password, filename);
115
fail_unless(result == 0, "Host should have been found");
116
fail_unless(strncmp(password, "none", 4) == 0,
117
"password should be 'none'");
118
fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
121
* Test over the size limit password / login!
122
* Test files with a bad format