18#include <cppunit/TestAssert.h>
54 CPPUNIT_ASSERT_NO_THROW(
ParseUrl(url));
101 CPPUNIT_ASSERT(manager !=
nullptr);
105 CPPUNIT_ASSERT(action !=
nullptr);
108 CPPUNIT_ASSERT(profile !=
nullptr);
109 CPPUNIT_ASSERT(profile->creator !=
nullptr);
110 CPPUNIT_ASSERT_EQUAL(
false, profile->isPwReq);
111 CPPUNIT_ASSERT_EQUAL(
false, profile->isAtomic);
114 CPPUNIT_ASSERT_EQUAL(
String(
"sample"),
String(action->name()));
119 action->run(sentry,
false);
120 CPPUNIT_ASSERT_EQUAL(1,(
int)sentry->
flags);
127 CPPUNIT_ASSERT(mgr !=
nullptr);
129 std::vector<AnyP::ProtocolType> validSchemes = {
136 mgrUrl.
host(
"localhost");
139 const std::vector<const char *> validActions = {
144 const std::vector<const char *> invalidActions = {
148 const std::vector<const char *> validParams = {
161 "?foo=?_weird?~`:[]stuff&bar=okay&&&&&&",
163 "?intlist=1,2,3,4,5",
166 "?string=1,2,3,4,[0]",
167 "?intlist=1,2,3,4,5&string=1,2,3,4,y"
170 const std::vector<const char *> invalidParams = {
191 const std::vector<const char *> validFragments = {
202 const auto insufficientPrefix = prefix.substr(0, prefix.length()-1);
204 for (
const auto &scheme : validSchemes) {
211 for (
const auto *action : validActions) {
212 for (
const auto *param : validParams) {
213 for (
const auto *frag : validFragments) {
215 bits.
append(insufficientPrefix);
220 mgr->testInvalidUrl(mgrUrl,
"insufficient prefix");
226 for (
const auto action: validActions) {
227 for (
const auto param: validParams) {
228 for (
const auto frag: validFragments) {
235 mgr->testValidUrl(mgrUrl);
241 for (
const auto action: validActions) {
242 for (
const auto invalidParam: invalidParams) {
243 for (
const auto frag: validFragments) {
247 bits.
append(invalidParam);
250 mgr->testInvalidUrl(mgrUrl, invalidParam);
static void Init()
initializes down-cased protocol scheme names array
void setScheme(const AnyP::ProtocolType &p, const char *str)
convert the URL scheme to that given
void port(const Port p)
reset authority port subcomponent
void host(const char *src)
Provides test code access to CacheManager internal symbols.
void testValidUrl(const AnyP::Uri &)
checks CacheManager parsing of the given valid URL
void testInvalidUrl(const AnyP::Uri &, const char *problem)
static CacheManager * GetInstance()
static const SBuf & WellKnownUrlPathPrefix()
initial URL path characters that identify cache manager requests
Mgr::Action::Pointer createNamedAction(const char *actionName)
Mgr::CommandPointer ParseUrl(const AnyP::Uri &)
customizes our test setup
SBuf & append(const SBuf &S)
CPPUNIT_TEST(testParseUrl)
CPPUNIT_TEST(testRegister)
CPPUNIT_TEST_SUITE(TestCacheManager)
implements test program's main() function while enabling customization
int run(int argc, char *argv[])
an std::runtime_error with thrower location info
void RegisterAction(char const *action, char const *desc, OBJH *handler, Protected, Atomic, Format)
CPPUNIT_TEST_SUITE_REGISTRATION(TestCacheManager)
static void dummy_action(StoreEntry *sentry)