Skip to content

Commit 766e01b

Browse files
committed
Pipeline fixes
- validate the special characters in project creation - added cors field to endpoint creation - modified the response for bucket updation - added cors to support function in api_base Change-Id: I04169ea76a6e5c36093873c5b3fd4fe8779313cb Reviewed-on: https://review.couchbase.org/c/TAF/+/228519 Reviewed-by: VIPUL BHARDWAJ <vipul.bhardwaj@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent daef88f commit 766e01b

8 files changed

Lines changed: 105 additions & 90 deletions

File tree

pytests/Capella/RestAPIv4/AppEndpoints/create_app_endpoints.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ def test_api_path(self):
122122
organization, project, cluster, appService,
123123
self.expected_res["name"], self.expected_res["deltaSync"],
124124
self.expected_res["bucket"], self.expected_res["scopes"],
125-
self.expected_res["userXattrKey"])
125+
self.expected_res["userXattrKey"], self.expected_res["cors"])
126126
if result.status_code == 429:
127127
self.handle_rate_limit(int(result.headers["Retry-After"]))
128128
result = self.capellaAPI.cluster_ops_apis.create_app_endpoint(
129129
organization, project, cluster, appService,
130130
self.expected_res["name"], self.expected_res["deltaSync"],
131131
self.expected_res["bucket"], self.expected_res["scopes"],
132-
self.expected_res["userXattrKey"])
132+
self.expected_res["userXattrKey"], self.expected_res["cors"])
133133
self.capellaAPI.cluster_ops_apis.app_endpoints_endpoint = \
134134
"/v4/organizations/{}/projects/{}/clusters/{}/appservices/{}/"\
135135
"appEndpoints"
@@ -146,26 +146,28 @@ def test_api_path(self):
146146
def test_authorization(self):
147147
failures = list()
148148
for testcase in self.v4_RBAC_injection_init([
149-
"organizationOwner", "projectOwner", "projectManager"
149+
"organizationOwner", "projectOwner", "projectManager"
150150
]):
151151
self.log.info("Executing test: {}".format(testcase["description"]))
152152
header = dict()
153153
self.auth_test_setup(testcase, failures, header,
154154
self.project_id, self.other_project_id)
155155
result = self.capellaAPI.cluster_ops_apis.create_app_endpoint(
156-
self.organisation_id, self.project_id, self.cluster_id,
156+
self.organisation_id, self.project_id, self.cluster_id,
157157
self.app_service_id,
158158
self.expected_res["name"], self.expected_res["deltaSync"],
159159
self.expected_res["bucket"], self.expected_res["scopes"],
160-
self.expected_res["userXattrKey"], header)
160+
self.expected_res["userXattrKey"],
161+
self.expected_res["cors"], header)
161162
if result.status_code == 429:
162163
self.handle_rate_limit(int(result.headers["Retry-After"]))
163164
result = self.capellaAPI.cluster_ops_apis.create_app_endpoint(
164-
self.organisation_id, self.project_id, self.cluster_id,
165+
self.organisation_id, self.project_id, self.cluster_id,
165166
self.app_service_id,
166167
self.expected_res["name"], self.expected_res["deltaSync"],
167168
self.expected_res["bucket"], self.expected_res["scopes"],
168169
self.expected_res["userXattrKey"],
170+
self.expected_res["cors"],
169171
header)
170172
self.validate_testcase(result, [201, 412], testcase, failures)
171173
if result.status_code == 201:
@@ -178,10 +180,10 @@ def test_authorization(self):
178180

179181
def test_query_parameters(self):
180182
self.log.debug(
181-
"Correct Params - organization ID: {}, project ID: {}, "
182-
"cluster ID: {}, appService ID: {}".format(
183-
self.organisation_id, self.project_id, self.cluster_id,
184-
self.app_service_id))
183+
"Correct Params - organization ID: {}, project ID: {}, "
184+
"cluster ID: {}, appService ID: {}".format(
185+
self.organisation_id, self.project_id, self.cluster_id,
186+
self.app_service_id))
185187
testcases = 0
186188
failures = list()
187189
for combination in self.create_path_combinations(
@@ -210,10 +212,10 @@ def test_query_parameters(self):
210212
testcase["expected_status_code"] = 405
211213
testcase["expected_error"] = ""
212214
elif any(variable in [
213-
int, bool, float, list, tuple, set, type(None)] for
214-
variable in [
215-
type(combination[0]), type(combination[1]),
216-
type(combination[2]), type(combination[3])]):
215+
int, bool, float, list, tuple, set, type(None)] for
216+
variable in [
217+
type(combination[0]), type(combination[1]),
218+
type(combination[2]), type(combination[3])]):
217219
testcase["expected_status_code"] = 400
218220
testcase["expected_error"] = {
219221
"code": 1000,
@@ -299,7 +301,8 @@ def test_query_parameters(self):
299301
testcase["clusterID"], testcase["appServiceID"],
300302
self.expected_res["name"], self.expected_res["deltaSync"],
301303
self.expected_res["bucket"], self.expected_res["scopes"],
302-
self.expected_res["userXattrKey"], **kwarg)
304+
self.expected_res["userXattrKey"], self.expected_res["cors"],
305+
**kwarg)
303306
if result.status_code == 429:
304307
self.handle_rate_limit(int(result.headers["Retry-After"]))
305308
result = self.capellaAPI.cluster_ops_apis.create_app_endpoint(
@@ -308,6 +311,7 @@ def test_query_parameters(self):
308311
self.expected_res["name"], self.expected_res["deltaSync"],
309312
self.expected_res["bucket"], self.expected_res["scopes"],
310313
self.expected_res["userXattrKey"],
314+
self.expected_res["cors"],
311315
**kwarg)
312316
self.validate_testcase(result, [201, 412], testcase, failures)
313317
if result.status_code == 201:
@@ -322,7 +326,7 @@ def test_query_parameters(self):
322326
def test_payload(self):
323327
testcases = list()
324328
for k in self.expected_res:
325-
if k in ["offline", "anonymous", "basicAuth", "oidc", "cors",
329+
if k in ["offline", "anonymous", "basicAuth", "oidc",
326330
"isRequireResync", "console", "state", "requireResync"]:
327331
continue
328332

@@ -353,8 +357,8 @@ def test_payload(self):
353357
elif (k in [
354358
"userXattrKey", "name", "bucket"
355359
] and not isinstance(v, str) or
356-
k == "deltaSync" and not isinstance(v, bool) or
357-
k == "scopes" and not isinstance(v, dict)):
360+
k == "deltaSync" and not isinstance(v, bool) or
361+
k == "scopes" and not isinstance(v, dict)):
358362
testcase["expected_status_code"] = 400
359363
testcase["expected_error"] = {
360364
"code": 1000,
@@ -429,15 +433,15 @@ def test_payload(self):
429433
self.organisation_id, self.project_id, self.cluster_id,
430434
self.app_service_id, testcase["name"], testcase["deltaSync"],
431435
testcase["bucket"], testcase["scopes"],
432-
testcase["userXattrKey"])
436+
testcase["userXattrKey"], self.expected_res["cors"])
433437
if res.status_code == 429:
434438
self.handle_rate_limit(int(res.headers["Retry-After"]))
435439
res = self.capellaAPI.cluster_ops_apis.create_bucket(
436440
self.organisation_id, self.project_id,
437441
self.cluster_id, self.app_service_id,
438442
testcase["name"], testcase["deltaSync"],
439443
testcase["bucket"], testcase["scopes"],
440-
testcase["userXattrKey"])
444+
testcase["userXattrKey"], self.expected_res["cors"])
441445
self.validate_testcase(res, [201, 412], testcase, failures,
442446
payloadTest=True)
443447
if res.status_code == 201:

pytests/Capella/RestAPIv4/AppEndpoints/delete_app_endpoints.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def test_api_path(self):
140140
if result.status_code == 429:
141141
self.handle_rate_limit(int(result.headers["Retry-After"]))
142142
result = self.capellaAPI.cluster_ops_apis.delete_app_endpoint(
143-
organization, project, cluster, appService, AppEndpointName)
143+
organization, project, cluster, appService,
144+
AppEndpointName)
144145
self.capellaAPI.cluster_ops_apis.app_endpoints_endpoint = \
145146
"/v4/organizations/{}/projects/{}/clusters/{}/appservices/{}/"\
146147
"appEndpoints"
@@ -151,7 +152,8 @@ def test_api_path(self):
151152
self.app_service_id,
152153
self.expected_res["name"], self.expected_res["deltaSync"],
153154
self.expected_res["bucket"], self.expected_res["scopes"],
154-
self.expected_res["userXattrKey"])
155+
self.expected_res["userXattrKey"],
156+
self.expected_res["cors"])
155157

156158
if failures:
157159
for fail in failures:
@@ -162,20 +164,20 @@ def test_api_path(self):
162164
def test_authorization(self):
163165
failures = list()
164166
for testcase in self.v4_RBAC_injection_init([
165-
"organizationOwner", "projectOwner", "projectManager"
167+
"organizationOwner", "projectOwner", "projectManager"
166168
]):
167169
self.log.info("Executing test: {}".format(testcase["description"]))
168170
header = dict()
169171
self.auth_test_setup(testcase, failures, header,
170172
self.project_id, self.other_project_id)
171173
result = self.capellaAPI.cluster_ops_apis.delete_app_endpoint(
172-
self.organisation_id, self.project_id, self.cluster_id,
174+
self.organisation_id, self.project_id, self.cluster_id,
173175
self.app_service_id, self.appEndpointName,
174176
header)
175177
if result.status_code == 429:
176178
self.handle_rate_limit(int(result.headers["Retry-After"]))
177179
result = self.capellaAPI.cluster_ops_apis.delete_app_endpoint(
178-
self.organisation_id, self.project_id, self.cluster_id,
180+
self.organisation_id, self.project_id, self.cluster_id,
179181
self.app_service_id, self.appEndpointName,
180182
header)
181183
self.validate_testcase(result, [202], testcase, failures)
@@ -194,11 +196,11 @@ def test_authorization(self):
194196

195197
def test_query_parameters(self):
196198
self.log.debug(
197-
"Correct Params - organization ID: {}, project ID: {}, "
198-
"cluster ID: {}, appService ID: {}, "
199-
"AppEndpoint Name: {}".format(
200-
self.organisation_id, self.project_id, self.cluster_id,
201-
self.app_service_id, self.appEndpointName))
199+
"Correct Params - organization ID: {}, project ID: {}, "
200+
"cluster ID: {}, appService ID: {}, "
201+
"AppEndpoint Name: {}".format(
202+
self.organisation_id, self.project_id, self.cluster_id,
203+
self.app_service_id, self.appEndpointName))
202204
testcases = 0
203205
failures = list()
204206
for combination in self.create_path_combinations(
@@ -229,11 +231,11 @@ def test_query_parameters(self):
229231
testcase["expected_status_code"] = 404
230232
testcase["expected_error"] = "404 page not found"
231233
elif any(variable in [
232-
int, bool, float, list, tuple, set, type(None)] for
233-
variable in [
234-
type(combination[0]), type(combination[1]),
235-
type(combination[2]), type(combination[3]),
236-
type(combination[4])]):
234+
int, bool, float, list, tuple, set, type(None)] for
235+
variable in [
236+
type(combination[0]), type(combination[1]),
237+
type(combination[2]), type(combination[3]),
238+
type(combination[4])]):
237239
testcase["expected_status_code"] = 400
238240
testcase["expected_error"] = {
239241
"code": 1000,
@@ -333,7 +335,8 @@ def test_query_parameters(self):
333335
self.app_service_id,
334336
self.expected_res["name"], self.expected_res["deltaSync"],
335337
self.expected_res["bucket"], self.expected_res["scopes"],
336-
self.expected_res["userXattrKey"])
338+
self.expected_res["userXattrKey"],
339+
self.expected_res["cors"])
337340

338341
if failures:
339342
for fail in failures:

pytests/Capella/RestAPIv4/AppEndpoints/get_app_endpoints.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ def setUp(self, nomenclature="AppEndpoints_GET"):
6565
self.app_service_id,
6666
self.expected_res["name"], self.expected_res["deltaSync"],
6767
self.expected_res["bucket"], self.expected_res["scopes"],
68-
self.expected_res["userXattrKey"])
68+
self.expected_res["userXattrKey"], self.expected_res["cors"])
6969
if result.status_code == 429:
7070
self.handle_rate_limit(int(result.headers["Retry-After"]))
7171
result = self.capellaAPI.cluster_ops_apis.create_app_endpoint(
7272
self.organisation_id, self.project_id, self.cluster_id,
7373
self.app_service_id,
7474
self.expected_res["name"], self.expected_res["deltaSync"],
7575
self.expected_res["bucket"], self.expected_res["scopes"],
76-
self.expected_res["userXattrKey"])
76+
self.expected_res["userXattrKey"], self.expected_res["cors"])
7777
if result.status_code == 412:
7878
self.log.debug("App endpoint {} already exists".format(
7979
self.expected_res["name"]))
@@ -214,8 +214,8 @@ def test_api_path(self):
214214
self.handle_rate_limit(int(result.headers["Retry-After"]))
215215
result = (self.capellaAPI.cluster_ops_apis.
216216
fetch_app_endpoint_info(
217-
organization, project, cluster, appService,
218-
AppEndpointName))
217+
organization, project, cluster, appService,
218+
AppEndpointName))
219219
self.capellaAPI.cluster_ops_apis.app_endpoints_endpoint = \
220220
"/v4/organizations/{}/projects/{}/clusters/{}/appservices/{}/"\
221221
"appEndpoints"
@@ -230,24 +230,24 @@ def test_api_path(self):
230230
def test_authorization(self):
231231
failures = list()
232232
for testcase in self.v4_RBAC_injection_init([
233-
"organizationOwner", "projectOwner", "projectDataReader",
234-
"projectViewer", "projectDataReaderWriter", "projectManager"
233+
"organizationOwner", "projectOwner", "projectDataReader",
234+
"projectViewer", "projectDataReaderWriter", "projectManager"
235235
]):
236236
self.log.info("Executing test: {}".format(testcase["description"]))
237237
header = dict()
238238
self.auth_test_setup(testcase, failures, header,
239239
self.project_id, self.other_project_id)
240240
result = self.capellaAPI.cluster_ops_apis.fetch_app_endpoint_info(
241-
self.organisation_id, self.project_id, self.cluster_id,
241+
self.organisation_id, self.project_id, self.cluster_id,
242242
self.app_service_id, self.appEndpointName,
243243
header)
244244
if result.status_code == 429:
245245
self.handle_rate_limit(int(result.headers["Retry-After"]))
246246
result = (self.capellaAPI.cluster_ops_apis.
247247
fetch_app_endpoint_info(
248-
self.organisation_id, self.project_id,
249-
self.cluster_id, self.app_service_id,
250-
self.appEndpointName, header))
248+
self.organisation_id, self.project_id,
249+
self.cluster_id, self.app_service_id,
250+
self.appEndpointName, header))
251251
self.validate_testcase(result, [200], testcase, failures)
252252

253253
if failures:
@@ -257,11 +257,11 @@ def test_authorization(self):
257257

258258
def test_query_parameters(self):
259259
self.log.debug(
260-
"Correct Params - organization ID: {}, project ID: {}, "
261-
"cluster ID: {}, appService ID: {}, "
262-
"AppEndpoint Name: {}".format(
263-
self.organisation_id, self.project_id, self.cluster_id,
264-
self.app_service_id, self.appEndpointName))
260+
"Correct Params - organization ID: {}, project ID: {}, "
261+
"cluster ID: {}, appService ID: {}, "
262+
"AppEndpoint Name: {}".format(
263+
self.organisation_id, self.project_id, self.cluster_id,
264+
self.app_service_id, self.appEndpointName))
265265
testcases = 0
266266
failures = list()
267267
for combination in self.create_path_combinations(
@@ -292,11 +292,11 @@ def test_query_parameters(self):
292292
testcase["expected_status_code"] = 404
293293
testcase["expected_error"] = "404 page not found"
294294
elif any(variable in [
295-
int, bool, float, list, tuple, set, type(None)] for
296-
variable in [
297-
type(combination[0]), type(combination[1]),
298-
type(combination[2]), type(combination[3]),
299-
type(combination[4])]):
295+
int, bool, float, list, tuple, set, type(None)] for
296+
variable in [
297+
type(combination[0]), type(combination[1]),
298+
type(combination[2]), type(combination[3]),
299+
type(combination[4])]):
300300
testcase["expected_status_code"] = 400
301301
testcase["expected_error"] = {
302302
"code": 1000,
@@ -386,10 +386,10 @@ def test_query_parameters(self):
386386
self.handle_rate_limit(int(result.headers["Retry-After"]))
387387
result = (self.capellaAPI.cluster_ops_apis.
388388
fetch_app_endpoint_info(
389-
testcase["organizationID"], testcase["projectID"],
390-
testcase["clusterID"], testcase["appServiceID"],
391-
testcase["AppEndpointName"],
392-
**kwarg))
389+
testcase["organizationID"], testcase["projectID"],
390+
testcase["clusterID"], testcase["appServiceID"],
391+
testcase["AppEndpointName"],
392+
**kwarg))
393393
self.validate_testcase(result, [200], testcase, failures)
394394

395395
if failures:

0 commit comments

Comments
 (0)