fixed some testws
This commit is contained in:
parent
2891deb47d
commit
b0136ceedf
@ -38,7 +38,7 @@ TEST_F(DirectiveTest, StringDirectiveParse)
|
||||
StringDirective directive("root", "");
|
||||
directive.parse("/var/www/html");
|
||||
|
||||
EXPECT_EQ(directive.getValueAs<std::string>(), "/var/www/html");
|
||||
EXPECT_EQ(directive.getValue().get<std::string>(), "/var/www/html");
|
||||
}
|
||||
|
||||
TEST_F(DirectiveTest, IntDirectiveCreation)
|
||||
@ -55,7 +55,7 @@ TEST_F(DirectiveTest, IntDirectiveParse)
|
||||
IntDirective directive("port", "0");
|
||||
directive.parse("9000");
|
||||
|
||||
EXPECT_EQ(directive.getValueAs<int>(), 9000);
|
||||
EXPECT_EQ(directive.getValue().get<int>(), 9000);
|
||||
}
|
||||
|
||||
TEST_F(DirectiveTest, BoolDirectiveCreation)
|
||||
@ -72,16 +72,16 @@ TEST_F(DirectiveTest, BoolDirectiveParsing)
|
||||
BoolDirective directive("test", "off");
|
||||
|
||||
directive.parse("on");
|
||||
EXPECT_TRUE(directive.getValueAs<bool>());
|
||||
EXPECT_TRUE(directive.getValue().get<bool>());
|
||||
|
||||
directive.parse("off");
|
||||
EXPECT_FALSE(directive.getValueAs<bool>());
|
||||
EXPECT_FALSE(directive.getValue().get<bool>());
|
||||
|
||||
directive.parse("true");
|
||||
EXPECT_TRUE(directive.getValueAs<bool>());
|
||||
EXPECT_TRUE(directive.getValue().get<bool>());
|
||||
|
||||
directive.parse("false");
|
||||
EXPECT_FALSE(directive.getValueAs<bool>());
|
||||
EXPECT_FALSE(directive.getValue().get<bool>());
|
||||
}
|
||||
|
||||
TEST_F(DirectiveTest, DirectiveFactoryCreateStringDirective)
|
||||
@ -90,7 +90,8 @@ TEST_F(DirectiveTest, DirectiveFactoryCreateStringDirective)
|
||||
|
||||
ASSERT_NE(directive, nullptr);
|
||||
EXPECT_EQ(directive->getName(), "server_name");
|
||||
EXPECT_TRUE(directive->getValue().holds<std::vector<std::string>>());
|
||||
EXPECT_TRUE(directive->getValue().holds<std::string>());
|
||||
EXPECT_EQ(directive->getValue().get<std::string>(), "example.com");
|
||||
}
|
||||
|
||||
TEST_F(DirectiveTest, DirectiveFactoryCreateIntDirective)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include <webserv/config/validation/ConfigValidator.hpp>
|
||||
|
||||
#include <webserv/config/validation/ValidationEngine.hpp> // for ValidationEngine
|
||||
#include <webserv/config/validation/directive_rules/AValidationRule.hpp> // for AValidationRule
|
||||
#include <webserv/config/validation/directive_rules/AllowedValuesRule.hpp> // for AllowedValuesRule
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
#include "webserv/config/validation/directive_rules/AValidationRule.hpp"
|
||||
|
||||
#include "webserv/config/validation/directive_rules/AllowedValuesRule.hpp"
|
||||
#include "webserv/config/validation/directive_rules/PortValidationRule.hpp"
|
||||
#include "webserv/config/validation/directive_rules/RequiredDirectiveRule.hpp"
|
||||
@ -7,30 +7,3 @@
|
||||
#include "webserv/config/validation/structural_rules/MinimumServerBlocksRule.hpp"
|
||||
#include "webserv/config/validation/structural_rules/RequiredLocationBlocksRule.hpp"
|
||||
#include "webserv/config/validation/structural_rules/UniqueServerNamesRule.hpp"
|
||||
|
||||
/**
|
||||
* Structural Validation Rules for WebServ Configuration
|
||||
*
|
||||
* These rules validate the overall structure and relationships
|
||||
* between configuration blocks, rather than individual directive values.
|
||||
*
|
||||
* Available Rules:
|
||||
*
|
||||
* 1. MinimumServerBlocksRule - Ensures global config has minimum number of server blocks
|
||||
* 2. RequiredLocationBlocksRule - Ensures each server has minimum number of location blocks
|
||||
* 3. UniqueServerNamesRule - Ensures all server names are unique across configuration
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* // In ValidationEngine setup
|
||||
* engine.addStructuralRule(std::make_unique<MinimumServerBlocksRule>(1));
|
||||
* engine.addStructuralRule(std::make_unique<RequiredLocationBlocksRule>(1));
|
||||
* engine.addStructuralRule(std::make_unique<UniqueServerNamesRule>());
|
||||
*
|
||||
* Each rule inherits from AStructuralValidationRule and can validate at:
|
||||
* - Global level (validateGlobal)
|
||||
* - Server level (validateServer)
|
||||
* - Location level (validateLocation)
|
||||
*
|
||||
* Rules have descriptive names and descriptions set in their constructors.
|
||||
*/
|
||||
Loading…
Reference in New Issue
Block a user