-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new rule for checking base uri equality.
- Loading branch information
Aleksander Lorenc
committed
Jan 26, 2020
1 parent
5f2b8a3
commit 1550af8
Showing
8 changed files
with
84 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from .rule_validator import RuleViolation | ||
from .rules_helper import get_path_verbs, get_apigateway_integration | ||
|
||
|
||
class IntegrationBaseUriRule: | ||
base_uri = '' | ||
|
||
def __init__(self, base_uri): | ||
self.rule_name = 'integration_base_uri' | ||
self.base_uri = base_uri | ||
|
||
def validate(self, spec): | ||
violations = [] | ||
for path in spec['paths']: | ||
for path_verb in get_path_verbs(spec, path): | ||
if path_verb == 'options': | ||
continue | ||
|
||
integration = get_apigateway_integration(spec, path, path_verb) | ||
integration_uri = integration['uri'] | ||
|
||
if not integration_uri.startswith(self.base_uri): | ||
violations.append(RuleViolation('integration_base_uri', | ||
message='Base URI "%s" not present at the beginning of URI "%s"' % (self.base_uri, integration_uri), | ||
path=path)) | ||
|
||
return violations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
openapi: "3.0.1" | ||
info: | ||
title: "Test" | ||
version: "1.0.0" | ||
paths: | ||
/test: | ||
get: | ||
responses: | ||
200: | ||
description: "200 response" | ||
x-amazon-apigateway-integration: | ||
type: "http" | ||
uri: "http://some.uri" | ||
passthroughBehavior: "when_no_match" | ||
httpMethod: "GET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters