Skip to content

Commit

Permalink
Adds tests for some APIs
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Jul 18, 2024
1 parent 0b033a9 commit f5220c1
Show file tree
Hide file tree
Showing 25 changed files with 263 additions and 8 deletions.
8 changes: 0 additions & 8 deletions spec/namespaces/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ paths:
x-operation-group: security.post_dashboards_info
x-version-added: '1.0'
description: Updates the current security-dashboards plugin configuration.
requestBody:
$ref: '#/components/requestBodies/security.post_dashboards_info'
responses:
'200':
$ref: '#/components/responses/security.post_dashboards_info@200'
Expand Down Expand Up @@ -1203,12 +1201,6 @@ components:
items:
$ref: '../schemas/security._common.yaml#/components/schemas/PatchOperation'
required: true
security.post_dashboards_info:
content:
application/json:
schema:
$ref: '../schemas/security._common.yaml#/components/schemas/DashboardsInfo'
required: false
security.update_audit_configuration:
content:
application/json:
Expand Down
50 changes: 50 additions & 0 deletions tests/security/with-api-prefix/account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test account endpoint.

prologues:
- path: _plugins/_security/api/internalusers/{username}
method: PUT
parameters:
username: test
request_body:
payload:
password: "myWeakPassword123!"
opendistro_security_roles: []
backend_roles: []
attributes: {}
response:
status: 200
chapters:
- synopsis: Get account details.
path: /_plugins/_security/api/account
method: GET
parameters:
format: json
response:
status: 200
# TODO: following test can be changed to interact with test user once https://github.com/opensearch-project/opensearch-api-specification/issues/438 is implemented
# NOTE: this test assumes that admin password is set to `myStrongPassword123!`, please update this test to correct password. One more reason to have the above feature implemented to avoid this.
- synopsis: Change password.
path: /_plugins/_security/api/account
method: PUT
request_body:
payload:
current_password: "myStrongPassword123!"
password: "myWeakPassword123!"
response:
status: 200
epilogues:
- path: /_plugins/_security/api/account
method: PUT
request_body:
payload:
current_password: "myWeakPassword123!"
password: "myStrongPassword123!"
response:
status: 200
- path: /_plugins/_security/api/internalusers/{username}
method: DELETE
parameters:
username: test
status: [200, 404]
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/action_groups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test action_groups endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/allowlist.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test allowlist endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/audit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test audit endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/authtoken.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test authtoken endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test cache endpoint.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/internal_users.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test internal users endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/migrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test migrate endpoint.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/nodesdn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test nodesdn endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/permissionsinfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test permissionsinfo endpoint.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test roles endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/rolesmapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test rolesmapping endpoint.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/securityconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test securityconfig endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/ssl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test ssl endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/tenancy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test tenancy endpoint.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/tenants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test tenants endpoints.
prologues:
chapters:
epilogues:
6 changes: 6 additions & 0 deletions tests/security/with-api-prefix/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test validate endpoint.
prologues:
chapters:
epilogues:
20 changes: 20 additions & 0 deletions tests/security/without-api-prefix/authinfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test authinfo endpoint.
chapters:
- synopsis: Get auth info.
path: /_plugins/_security/authinfo
method: GET
parameters:
auth_type: basic
verbose: false
response:
status: [200, 500]
- synopsis: Get auth info via POST.
path: /_plugins/_security/authinfo
method: POST
parameters:
auth_type: basic
verbose: false
response:
status: [200, 500]
14 changes: 14 additions & 0 deletions tests/security/without-api-prefix/dashboardsinfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test dashboardsinfo endpoint.
chapters:
- synopsis: Get dashboards info.
path: /_plugins/_security/dashboardsinfo
method: GET
response:
status: [200, 500]
- synopsis: Get dashboards info via POST.
path: /_plugins/_security/dashboardsinfo
method: POST
response:
status: [200, 500]
18 changes: 18 additions & 0 deletions tests/security/without-api-prefix/health.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test health endpoint.
chapters:
- synopsis: Get security health info.
path: /_plugins/_security/health
method: GET
parameters:
mode: strict
response:
status: 200
- synopsis: Get security health info via POST.
path: /_plugins/_security/health
method: POST
parameters:
mode: strict
response:
status: 200
11 changes: 11 additions & 0 deletions tests/security/without-api-prefix/sslinfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test sslinfo endpoint.
chapters:
- synopsis: Get ssl info.
path: /_opendistro/_security/sslinfo
method: GET
parameters:
show_dn: false
response:
status: [200, 500]
15 changes: 15 additions & 0 deletions tests/security/without-api-prefix/tenantinfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test tenantinfo endpoint.
chapters:
- synopsis: Get tenant info.
path: /_plugins/_security/tenantinfo
method: GET
response:
status: [200, 500]
- synopsis: Get tenant info via POST.
path: /_plugins/_security/tenantinfo
method: POST
response:
status: [200, 500]

19 changes: 19 additions & 0 deletions tests/security/without-api-prefix/upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test upgrade eligibility endpoints.
chapters:
- synopsis: Check whether an upgrade can be performed.
version: '>= 2.14'
path: /_plugins/_security/_upgrade_check
method: GET
response:
status: 200
- synopsis: Perform the upgrade.
version: '>= 2.14'
path: /_plugins/_security/_upgrade_perform
method: POST
request_body:
payload:
config: ["roles"]
response:
status: 200
20 changes: 20 additions & 0 deletions tests/security/without-api-prefix/whoami.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test whoami endpoints.
chapters:
- synopsis: Get current user info.
path: /_plugins/_security/whoami
method: GET
response:
status: [200, 500]
- synopsis: Get current user info via POST.
path: /_plugins/_security/whoami
method: POST
response:
status: [200, 500]
- synopsis: Get current user info from protected endpoint.
version: '>= 2.11'
path: /_plugins/_security/whoamiprotected
method: GET
response:
status: [200, 500]

0 comments on commit f5220c1

Please sign in to comment.