Skip to content

Commit

Permalink
Unit tests for check security rules. (#75)
Browse files Browse the repository at this point in the history
* Unit tests for check security rules.

* format

* Address review comments.

* Fix typos
  • Loading branch information
sarvaniv authored Feb 13, 2017
1 parent 0c001df commit f90136c
Show file tree
Hide file tree
Showing 3 changed files with 482 additions and 6 deletions.
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

0 comments on commit f90136c

Please sign in to comment.