Skip to content

Commit

Permalink
Added test for apiKey security with query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
macisamuele committed Oct 6, 2016
1 parent 0aa191a commit 129b62a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test-data/2.0/security/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"apiKey3": {
"type": "apiKey",
"name": "apiKey3",
"in": "header"
"in": "query"
},
"oauth2": {
"type": "oauth2",
Expand Down
12 changes: 8 additions & 4 deletions tests/operation/security_object_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,27 @@ def test_security_parameter_cannot_override_path_or_operation_parameter(


@pytest.mark.parametrize(
'resource, operation, headers, expect_to_raise',
'resource, operation, query, headers, expect_to_raise',
[
('example1', 'get_example1', {'sec1': 'sec1', 'sec2': 'sec2'}, True),
('example2', 'get_example2', {}, True),
('example3', 'get_example3', {'sec1': 'sec1', 'sec2': 'sec2'}, False),
('example1', 'get_example1', {}, {'sec1': 'sec1', 'sec2': 'sec2'}, True),
('example2', 'get_example2', {}, {}, True),
('example2', 'get_example2', {}, {'sec3': 'sec3'}, True),
('example2', 'get_example2', {'sec3': 'sec3'}, {}, False),
('example3', 'get_example3', {}, {'sec1': 'sec1', 'sec2': 'sec2'}, False),
]
)
def test_only_one_security_definition_in_use_at_time(
security_spec,
resource,
operation,
query,
headers,
expect_to_raise,
):
request = Mock(
spec=IncomingRequest,
headers=headers,
query=query,
)

op = security_spec.resources[resource].operations[operation]
Expand Down

0 comments on commit 129b62a

Please sign in to comment.