Skip to content

Commit b6cb49e

Browse files
committed
Add validation tests for namespaced key_sets and keys
1 parent 835e7da commit b6cb49e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

microservices/gatewayApi/tests/routes/v2/test_gateway_err_validations.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,40 @@ def test_valid_strict_dp_upstream(client):
145145
}
146146
response = client.put('/v2/namespaces/mytest3/gateway', json=data)
147147
assert response.status_code == 200
148+
149+
150+
def test_key_sets_and_keys_require_tags(client):
151+
configFile = '''
152+
key_sets:
153+
- name: my-key-set
154+
tags: ["ns.mytest", "another"]
155+
keys:
156+
- name: my-key
157+
tags: ["ns.mytest", "another"]
158+
'''
159+
160+
data = {
161+
"configFile": configFile,
162+
"dryRun": True
163+
}
164+
response = client.put('/v2/namespaces/mytest/gateway', json=data)
165+
assert response.status_code == 200
166+
167+
168+
def test_key_sets_and_keys_invalid_tags(client):
169+
configFile = '''
170+
key_sets:
171+
- name: my-key-set
172+
tags: ["ns.other", "another"]
173+
keys:
174+
- name: my-key
175+
tags: ["ns.mytest", "another"]
176+
'''
177+
178+
data = {
179+
"configFile": configFile,
180+
"dryRun": True
181+
}
182+
response = client.put('/v2/namespaces/mytest/gateway', json=data)
183+
assert response.status_code == 400
184+
assert "invalid ns tag ns.other" in json.dumps(response.json)

0 commit comments

Comments
 (0)