From f46fe7597fa0999d7b7f06da97be3ee6afdcb5aa Mon Sep 17 00:00:00 2001 From: serassio <> Date: Sun, 18 Dec 2005 16:23:39 +0000 Subject: [PATCH] Updated "make check" support: - Added Negotiate schema support - Allow 'make check' with --enable-ssl - Updated new HttpReply class usage --- src/Makefile.am | 14 +++++++---- src/Makefile.in | 14 +++++++---- src/auth/negotiate/auth_negotiate.h | 3 +++ src/auth/ntlm/auth_ntlm.h | 3 +++ src/tests/stub_HttpReply.cc | 13 +++++----- src/tests/testAuth.cc | 37 +++++++++++++++++++++++++---- src/tests/testAuth.h | 14 +++++++++++ src/tests/testCoss.cc | 6 ++--- src/tests/testNull.cc | 5 ++-- src/tests/testUfs.cc | 6 ++--- 10 files changed, 86 insertions(+), 29 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 5b3eb82c96..4f2d9deeee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.121 2005/12/15 22:25:24 hno Exp $ +# $Id: Makefile.am,v 1.122 2005/12/18 09:23:39 serassio Exp $ # # Uncomment and customize the following to suit your needs: # @@ -1045,7 +1045,8 @@ tests_testStore_SOURCES= tests/testStore.cc \ tests_testStore_LDADD= \ -L../lib -lmiscutil \ - @SQUID_CPPUNIT_LA@ + @SQUID_CPPUNIT_LA@ \ + @SSLLIB@ tests_testStore_LDFLAGS = $(LIBADD_DL) tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ @SQUID_CPPUNIT_LA@ @@ -1105,7 +1106,8 @@ tests_testUfs_SOURCES= tests/testUfs.cc \ tests/testUfs.h \ $(SWAP_TEST_SOURCES) tests_testUfs_LDADD= \ - $(SWAP_TEST_LDADD) + $(SWAP_TEST_LDADD) \ + @SSLLIB@ tests_testUfs_LDFLAGS = $(LIBADD_DL) tests_testUfs_DEPENDENCIES = \ $(SWAP_TEST_DS) @@ -1115,7 +1117,8 @@ tests_testCoss_SOURCES= tests/testCoss.cc \ tests/testCoss.h \ $(SWAP_TEST_SOURCES) tests_testCoss_LDADD= \ - $(SWAP_TEST_LDADD) + $(SWAP_TEST_LDADD) \ + @SSLLIB@ tests_testCoss_LDFLAGS = $(LIBADD_DL) tests_testCoss_DEPENDENCIES = \ $(SWAP_TEST_DS) @@ -1125,7 +1128,8 @@ tests_testNull_SOURCES= tests/testNull.cc \ tests/testNull.h \ $(SWAP_TEST_SOURCES) tests_testNull_LDADD= \ - $(SWAP_TEST_LDADD) + $(SWAP_TEST_LDADD) \ + @SSLLIB@ tests_testNull_LDFLAGS = $(LIBADD_DL) tests_testNull_DEPENDENCIES = \ $(SWAP_TEST_DS) diff --git a/src/Makefile.in b/src/Makefile.in index 764114ccf7..5f2348f698 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -17,7 +17,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.358 2005/12/16 01:10:45 hno Exp $ +# $Id: Makefile.in,v 1.359 2005/12/18 09:23:39 serassio Exp $ # # Uncomment and customize the following to suit your needs: # @@ -1576,7 +1576,8 @@ tests_testStore_SOURCES = tests/testStore.cc \ tests_testStore_LDADD = \ -L../lib -lmiscutil \ - @SQUID_CPPUNIT_LA@ + @SQUID_CPPUNIT_LA@ \ + @SSLLIB@ tests_testStore_LDFLAGS = $(LIBADD_DL) tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ @@ -1639,7 +1640,8 @@ tests_testUfs_SOURCES = tests/testUfs.cc \ $(SWAP_TEST_SOURCES) tests_testUfs_LDADD = \ - $(SWAP_TEST_LDADD) + $(SWAP_TEST_LDADD) \ + @SSLLIB@ tests_testUfs_LDFLAGS = $(LIBADD_DL) tests_testUfs_DEPENDENCIES = \ @@ -1651,7 +1653,8 @@ tests_testCoss_SOURCES = tests/testCoss.cc \ $(SWAP_TEST_SOURCES) tests_testCoss_LDADD = \ - $(SWAP_TEST_LDADD) + $(SWAP_TEST_LDADD) \ + @SSLLIB@ tests_testCoss_LDFLAGS = $(LIBADD_DL) tests_testCoss_DEPENDENCIES = \ @@ -1663,7 +1666,8 @@ tests_testNull_SOURCES = tests/testNull.cc \ $(SWAP_TEST_SOURCES) tests_testNull_LDADD = \ - $(SWAP_TEST_LDADD) + $(SWAP_TEST_LDADD) \ + @SSLLIB@ tests_testNull_LDFLAGS = $(LIBADD_DL) tests_testNull_DEPENDENCIES = \ diff --git a/src/auth/negotiate/auth_negotiate.h b/src/auth/negotiate/auth_negotiate.h index 488a5cc6f1..c88dedc5ea 100644 --- a/src/auth/negotiate/auth_negotiate.h +++ b/src/auth/negotiate/auth_negotiate.h @@ -12,6 +12,8 @@ #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ +#ifndef __AUTH_AUTHENTICATE_STATE_T__ +#define __AUTH_AUTHENTICATE_STATE_T__ typedef enum { AUTHENTICATE_STATE_NONE, AUTHENTICATE_STATE_INITIAL, @@ -31,6 +33,7 @@ typedef struct } authenticateStateData; +#endif class NegotiateUser : public AuthUser { diff --git a/src/auth/ntlm/auth_ntlm.h b/src/auth/ntlm/auth_ntlm.h index 7606ed30b8..4df71aa456 100644 --- a/src/auth/ntlm/auth_ntlm.h +++ b/src/auth/ntlm/auth_ntlm.h @@ -12,6 +12,8 @@ #define DefaultAuthenticateChildrenMax 32 /* 32 processes */ +#ifndef __AUTH_AUTHENTICATE_STATE_T__ +#define __AUTH_AUTHENTICATE_STATE_T__ typedef enum { AUTHENTICATE_STATE_NONE, AUTHENTICATE_STATE_INITIAL, @@ -31,6 +33,7 @@ typedef struct } authenticateStateData; +#endif class NTLMUser : public AuthUser { diff --git a/src/tests/stub_HttpReply.cc b/src/tests/stub_HttpReply.cc index 097e8c76d3..25dba02c0b 100644 --- a/src/tests/stub_HttpReply.cc +++ b/src/tests/stub_HttpReply.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_HttpReply.cc,v 1.1 2005/01/03 16:08:27 robertc Exp $ + * $Id: stub_HttpReply.cc,v 1.2 2005/12/18 09:23:40 serassio Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Robert Collins @@ -36,26 +36,25 @@ #include "HttpReply.h" void -httpReplyAbsorb(HttpReply * rep, HttpReply * new_rep) +HttpReply::absorb(HttpReply * new_rep) { fatal ("Not implemented"); } void -httpReplySetHeaders(HttpReply * rep, HttpVersion ver, http_status status, - const char *reason, const char *ctype, int clen, time_t lmt, time_t expires) +HttpReply::setHeaders(HttpVersion ver, http_status status, const char *reason, + const char *ctype, int clen, time_t lmt, time_t expires) { fatal ("Not implemented"); } void -httpReplyPackHeadersInto(const HttpReply * rep, Packer * p) +HttpReply::packHeadersInto(Packer * p) const { fatal ("Not implemented"); } -void -httpReplyReset(HttpReply * rep) +void HttpReply::reset() { fatal ("Not implemented"); } diff --git a/src/tests/testAuth.cc b/src/tests/testAuth.cc index 1a9638dd8a..0436179137 100644 --- a/src/tests/testAuth.cc +++ b/src/tests/testAuth.cc @@ -14,6 +14,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( testAuthUserRequest ); CPPUNIT_TEST_SUITE_REGISTRATION( testAuthBasicUserRequest ); CPPUNIT_TEST_SUITE_REGISTRATION( testAuthDigestUserRequest ); CPPUNIT_TEST_SUITE_REGISTRATION( testAuthNTLMUserRequest ); +CPPUNIT_TEST_SUITE_REGISTRATION( testAuthNegotiateUserRequest ); /* Instantiate all auth framework types */ void @@ -34,10 +35,11 @@ find_proxy_auth(char const *type) char const * proxy_auths[][2]= { {"basic","Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="}, {"digest", "Digest username=\"robertdig\", realm=\"Squid proxy-caching web server\", nonce=\"yy8rQXjEWwixXVBj\", uri=\"/images/bg8.gif\", response=\"f75a7d3edd48d93c681c75dc4fb58700\", qop=auth, nc=00000012, cnonce=\"e2216641961e228e\" "}, - {"ntlm", "NTLM "} + {"ntlm", "NTLM "}, + {"negotiate", "Negotiate "} }; - for (unsigned count = 0; count < 3 ; count++) { + for (unsigned count = 0; count < 4 ; count++) { if (strcasecmp(type, proxy_auths[count][0]) == 0) return proxy_auths[count][1]; } @@ -109,6 +111,8 @@ fake_auth_setup() char const *ntlm_parms[]= {"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd"}; + char const *negotiate_parms[]= {"program /home/robertc/install/squid/libexec/digest_pw_auth /home/robertc/install/squid/etc/digest.pwd"}; + struct _scheme_params { char const *name; char const **params; @@ -117,9 +121,10 @@ fake_auth_setup() params[]={ {"digest", digest_parms, 2}, {"basic", basic_parms, 2}, - {"ntlm", ntlm_parms, 1}}; + {"ntlm", ntlm_parms, 1}, + {"negotiate", negotiate_parms, 1}}; - for (unsigned scheme=0; scheme < 3; scheme++) + for (unsigned scheme=0; scheme < 4; scheme++) setup_scheme(getConfig(params[scheme].name), params[scheme].params, params[scheme].paramlength); authenticateInit(&config); @@ -232,3 +237,27 @@ testAuthNTLMUserRequest::username() CPPUNIT_ASSERT_EQUAL(0, strcmp("John", temp->username())); delete temp; } + +#include "auth/negotiate/auth_negotiate.h" +/* AuthNegotiateUserRequest::AuthNegotiateUserRequest works + */ +void +testAuthNegotiateUserRequest::construction() +{ + AuthNegotiateUserRequest(); + AuthNegotiateUserRequest *temp=new AuthNegotiateUserRequest(); + delete temp; +} + +void +testAuthNegotiateUserRequest::username() +{ + AuthNegotiateUserRequest(); + AuthNegotiateUserRequest *temp=new AuthNegotiateUserRequest(); + NegotiateUser *user=new NegotiateUser(AuthConfig::Find("negotiate")); + user->username("John"); + temp->user(user); + user->addRequest(temp); + CPPUNIT_ASSERT_EQUAL(0, strcmp("John", temp->username())); + delete temp; +} diff --git a/src/tests/testAuth.h b/src/tests/testAuth.h index faef6fbbd6..c59b09fde2 100644 --- a/src/tests/testAuth.h +++ b/src/tests/testAuth.h @@ -87,5 +87,19 @@ protected: void username(); }; +class testAuthNegotiateUserRequest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE( testAuthNegotiateUserRequest ); + CPPUNIT_TEST( construction ); + CPPUNIT_TEST( username ); + CPPUNIT_TEST_SUITE_END(); + +public: + +protected: + void construction(); + void username(); +}; + #endif diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index 89a51aa000..44ec10dfe4 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -187,8 +187,8 @@ testCoss::testCossSearch() flags.cachable = 1; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpVersion version(1, 0); - /* We are allowed to do this typecast */ - httpReplySetHeaders((HttpReply *)pe->getReply(), version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); + HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const + rep->setHeaders(version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); storeSetPublicKey(pe); @@ -197,7 +197,7 @@ testCoss::testCossSearch() { Packer p; packerToStoreInit(&p, pe); - httpReplyPackHeadersInto(pe->getReply(), &p); + pe->getReply()->packHeadersInto(&p); packerClean(&p); } diff --git a/src/tests/testNull.cc b/src/tests/testNull.cc index 2fef3fe770..7abf909770 100644 --- a/src/tests/testNull.cc +++ b/src/tests/testNull.cc @@ -157,7 +157,8 @@ testNull::testNullSearch() StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpVersion version(1, 0); /* We are allowed to do this typecast */ - httpReplySetHeaders((HttpReply *)pe->getReply(), version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); + HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const + rep->setHeaders(version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); storeSetPublicKey(pe); @@ -166,7 +167,7 @@ testNull::testNullSearch() { Packer p; packerToStoreInit(&p, pe); - httpReplyPackHeadersInto(pe->getReply(), &p); + pe->getReply()->packHeadersInto(&p); packerClean(&p); } diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index 578e3af405..0b0d594b9e 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -121,8 +121,8 @@ testUfs::testUfsSearch() flags.cachable = 1; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpVersion version(1, 0); - /* We are allowed to do this typecast */ - httpReplySetHeaders((HttpReply *)pe->getReply(), version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); + HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const + rep->setHeaders(version, HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); storeSetPublicKey(pe); @@ -131,7 +131,7 @@ testUfs::testUfsSearch() { Packer p; packerToStoreInit(&p, pe); - httpReplyPackHeadersInto(pe->getReply(), &p); + pe->getReply()->packHeadersInto(&p); packerClean(&p); } -- 2.47.3