-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4da2829
commit f21d328
Showing
7 changed files
with
234 additions
and
8 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
33 changes: 33 additions & 0 deletions
33
microservices/gatewayApi/tests/routes/v2/test_gateway_api.py
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,33 @@ | ||
import yaml | ||
import pytest | ||
import json | ||
from v1.routes.gateway import validate_upstream | ||
from tests.testutils import trimleft | ||
from unittest import mock | ||
|
||
def test_error_call_with_missing_config(client): | ||
data={ | ||
"dryRun": True | ||
} | ||
response = client.put('/v2/namespaces/mytest/gateway', json=data) | ||
assert response.status_code == 400 | ||
assert json.dumps(response.json) == '{"error": "Missing input"}' | ||
|
||
|
||
def test_error_call_with_empty_config(client): | ||
data={ | ||
"configFile": '', | ||
"dryRun": True | ||
} | ||
response = client.put('/v2/namespaces/mytest/gateway', json=data) | ||
assert response.status_code == 400 | ||
assert json.dumps(response.json) == '{"error": "Missing input"}' | ||
|
||
def test_success_call_with_empty_document(client): | ||
data={ | ||
"configFile": '---', | ||
"dryRun": True | ||
} | ||
response = client.put('/v2/namespaces/mytest/gateway', json=data) | ||
assert response.status_code == 200 | ||
assert json.dumps(response.json) == '{"message": "Dry-run. No changes applied.", "results": "Deck reported no changes"}' |
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
29 changes: 29 additions & 0 deletions
29
microservices/gatewayApi/tests/routes/v2/test_gateway_local.py
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,29 @@ | ||
import yaml | ||
import pytest | ||
import json | ||
from v1.routes.gateway import validate_upstream | ||
from tests.testutils import trimleft | ||
from unittest import mock | ||
|
||
def test_local_host(client): | ||
configFile = ''' | ||
services: | ||
- name: my-service | ||
host: myupstream.local | ||
tags: ["ns.mytest", "another"] | ||
routes: | ||
- name: route-1 | ||
hosts: [ myapi.cluster.local ] | ||
tags: ["ns.mytest", "another2"] | ||
plugins: | ||
- name: acl-auth | ||
tags: ["ns.mytest"] | ||
''' | ||
|
||
data={ | ||
"configFile": configFile, | ||
"dryRun": False | ||
} | ||
response = client.put('/v2/namespaces/mytest/gateway', json=data) | ||
assert response.status_code == 200 | ||
assert json.dumps(response.json) == '{"message": "Sync successful.", "results": "Deck reported no changes"}' |
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