23#if HAVE_AUTH_MODULE_BASIC
26#if HAVE_AUTH_MODULE_DIGEST
29#if HAVE_AUTH_MODULE_NTLM
32#if HAVE_AUTH_MODULE_NEGOTIATE
41char const *
stub_config=
"auth_param digest program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd\n"
42 "auth_param digest children 5\n"
43 "auth_param digest realm Squid proxy-caching web server\n"
44 "auth_param digest nonce_garbage_interval 5 minutes\n"
45 "auth_param digest nonce_max_duration 30 minutes\n"
46 "auth_param digest nonce_max_count 50\n";
52 char const * proxy_auths[][2]= { {
"basic",
"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="},
54 {
"digest",
"Digest username=\"robertdig\", realm=\"Squid proxy-caching web server\", nonce=\"yy8rQXjEWwixXVBj\", uri=\"/images/bg8.gif\", response=\"f75a7d3edd48d93c681c75dc4fb58700\", qop=auth, nc=00000012, cnonce=\"e2216641961e228e\" "},
56 {
"negotiate",
"Negotiate "}
59 for (
unsigned count = 0; count < 4 ; ++count) {
60 if (strcasecmp(type, proxy_auths[count][0]) == 0)
61 return proxy_auths[count][1];
79 if (theScheme ==
NULL) {
84 config.push_back(theScheme->createConfig());
85 scheme = config.back();
98 for (
unsigned position=0; position < param_count; ++position) {
99 char *param_str=
xstrdup(params[position]);
102 scheme->parse(scheme, config.size(), param_str);
110 static bool setup(
false);
119 char const *digest_parms[]= {
"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd",
123 char const *basic_parms[]= {
"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd",
127 char const *ntlm_parms[]= {
"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd"};
129 char const *negotiate_parms[]= {
"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd"};
131 struct _scheme_params {
134 unsigned paramlength;
137 params[]= { {
"digest", digest_parms, 2},
138 {
"basic", basic_parms, 2},
139 {
"ntlm", ntlm_parms, 1},
140 {
"negotiate", negotiate_parms, 1}
143 for (
unsigned scheme=0; scheme < 4; ++scheme) {
145 schemeConfig =
getConfig(params[scheme].name);
146 if (schemeConfig !=
NULL)
148 params[scheme].paramlength);
150 fprintf(stderr,
"Skipping unknown authentication scheme '%s'.\n",
151 params[scheme].name);
169 AuthUserRequest::Pointer authRequest = Auth::Config::CreateAuthUser(
find_proxy_auth((*i)->type()));
170 CPPUNIT_ASSERT(authRequest !=
NULL);
188 AuthUserRequest::Pointer authRequest = Auth::Config::CreateAuthUser(
find_proxy_auth((*i)->type()));
189 CPPUNIT_ASSERT_EQUAL(authRequest->scheme(), *i);
193#if HAVE_AUTH_MODULE_BASIC
199TestAuthBasicUserRequest::construction()
201 AuthBasicUserRequest();
202 AuthBasicUserRequest *temp=
new AuthBasicUserRequest();
207TestAuthBasicUserRequest::username()
209 AuthUserRequest::Pointer temp =
new AuthBasicUserRequest();
210 Auth::Basic::User *basic_auth=
new Auth::Basic::User(Auth::Config::Find(
"basic"));
211 basic_auth->username(
"John");
212 temp->user(basic_auth);
213 CPPUNIT_ASSERT_EQUAL(0, strcmp(
"John", temp->username()));
217#if HAVE_AUTH_MODULE_DIGEST
223TestAuthDigestUserRequest::construction()
225 AuthDigestUserRequest();
226 AuthDigestUserRequest *temp=
new AuthDigestUserRequest();
231TestAuthDigestUserRequest::username()
233 AuthUserRequest::Pointer temp =
new AuthDigestUserRequest();
234 Auth::Digest::User *duser=
new Auth::Digest::User(Auth::Config::Find(
"digest"));
235 duser->username(
"John");
237 CPPUNIT_ASSERT_EQUAL(0, strcmp(
"John", temp->username()));
241#if HAVE_AUTH_MODULE_NTLM
247TestAuthNtlmUserRequest::construction()
249 AuthNTLMUserRequest();
250 AuthNTLMUserRequest *temp=
new AuthNTLMUserRequest();
255TestAuthNtlmUserRequest::username()
257 AuthUserRequest::Pointer temp =
new AuthNTLMUserRequest();
258 Auth::Ntlm::User *nuser=
new Auth::Ntlm::User(Auth::Config::Find(
"ntlm"));
259 nuser->username(
"John");
261 CPPUNIT_ASSERT_EQUAL(0, strcmp(
"John", temp->username()));
265#if HAVE_AUTH_MODULE_NEGOTIATE
271TestAuthNegotiateUserRequest::construction()
273 AuthNegotiateUserRequest();
274 AuthNegotiateUserRequest *temp=
new AuthNegotiateUserRequest();
279TestAuthNegotiateUserRequest::username()
281 AuthUserRequest::Pointer temp =
new AuthNegotiateUserRequest();
282 Auth::Negotiate::User *nuser=
new Auth::Negotiate::User(Auth::Config::Find(
"negotiate"));
283 nuser->username(
"John");
285 CPPUNIT_ASSERT_EQUAL(0, strcmp(
"John", temp->username()));
void authenticateInit(Auth::ConfigVector *config)
static std::vector< Scheme::Pointer > & GetSchemes()
static Scheme::Pointer Find(const char *)
std::vector< Scheme::Pointer >::iterator iterator
static void SetCfgLine(char *line)
Set the configuration file line to parse.
static int Levels[MAX_DEBUG_SECTIONS]
implements test program's main() function while enabling customization
int run(int argc, char *argv[])
std::vector< Auth::SchemeConfig * > ConfigVector
int main(int argc, char *argv[])
static void fake_auth_setup()
CPPUNIT_TEST_SUITE_REGISTRATION(TestAuth)
static char const * find_proxy_auth(char const *type)
static void setup_scheme(Auth::Config *scheme, char const **params, unsigned param_count)
static Auth::Config * getConfig(char const *type_str)