Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for check security rules. #75

Merged
merged 4 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions contrib/endpoints/src/api_manager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,18 @@ cc_test(
"//external:googletest_main",
],
)

cc_test(
name = "check_security_rules_test",
size = "small",
srcs = [
"check_security_rules_test.cc",
"mock_request.h",
],
linkstatic = 1,
deps = [
":api_manager",
":mock_api_manager_environment",
"//external:googletest_main",
],
)
12 changes: 6 additions & 6 deletions contrib/endpoints/src/api_manager/check_security_rules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ const char kFirebaseCreateMethod[] = "create";
const char kFirebaseGetMethod[] = "get";
const char kFirebaseDeleteMethod[] = "delete";
const char kFirebaseUpdateMethod[] = "update";
const char kV1[] = "v1/";
const char kV1[] = "/v1";
const char kTestQuery[] = ":test?alt=json";
const char kProjects[] = "projects/";
const char kReleases[] = "/releases/";
const char kProjects[] = "/projects";
const char kReleases[] = "/releases";
const char kRulesetName[] = "rulesetName";
const char kTestResults[] = "testResults";
const char kState[] = "state";
Expand All @@ -71,14 +71,14 @@ std::string GetReleaseName(const context::RequestContext &context) {

std::string GetRulesetTestUri(const context::RequestContext &context,
const std::string &ruleset_id) {
return context.service_context()->config()->GetFirebaseServer() + kV1 +
return context.service_context()->config()->GetFirebaseServer() + kV1 + "/" +
ruleset_id + kTestQuery;
}

std::string GetReleaseUrl(const context::RequestContext &context) {
return context.service_context()->config()->GetFirebaseServer() + kV1 +
kProjects + context.service_context()->project_id() + kReleases +
GetReleaseName(context);
kProjects + "/" + context.service_context()->project_id() + kReleases +
"/" + GetReleaseName(context);
}

std::string GetOperation(const std::string &httpMethod) {
Expand Down
Loading