Skip to content

Commit

Permalink
Adds base tests for all 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 23, 2024
1 parent 0439eb2 commit f65a6cf
Show file tree
Hide file tree
Showing 22 changed files with 642 additions and 48 deletions.
8 changes: 3 additions & 5 deletions tests/security/with-api-prefix/account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Test account endpoint.
version: '>= 2.12' # Should be removed once TODO referenced above is addressed

prologues:
- path: _plugins/_security/api/internalusers/{username}
- path: /_plugins/_security/api/internalusers/{username}
method: PUT
parameters:
username: test
Expand All @@ -14,8 +14,7 @@ prologues:
opendistro_security_roles: []
backend_roles: []
attributes: {}
response:
status: 200
status: 200
chapters:
- synopsis: Get account details.
path: /_plugins/_security/api/account
Expand All @@ -42,8 +41,7 @@ epilogues:
payload:
current_password: myWeakPassword123!
password: myStrongPassword123!
response:
status: 200
status: 200
- path: /_plugins/_security/api/internalusers/{username}
method: DELETE
parameters:
Expand Down
75 changes: 75 additions & 0 deletions tests/security/with-api-prefix/action_groups.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,81 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test action_groups endpoints.

prologues:
- path: /_plugins/_security/api/actiongroups/{action_group}
method: PUT
parameters:
action_group: test
request_body:
payload:
reserved:
hidden:
allowed_actions: []
type:
description:
static:
status: 200
chapters:
- synopsis: Get action groups bulk.
path: /_plugins/_security/api/actiongroups
method: GET
response:
status: 200
- synopsis: Patch action groups bulk.
path: /_plugins/_security/api/actiongroups
method: PATCH
request_body:
payload:
op:
path:
value:
response:
status: 200
- synopsis: Get action group.
path: /_plugins/_security/api/actiongroups/{action_group}
method: GET
parameters:
action_group: test
response:
status: 200
- synopsis: Create action group.
path: /_plugins/_security/api/actiongroups/{action_group}
method: PUT
parameters:
action_group: test2
request_body:
payload:
reserved:
hidden:
allowed_actions: []
type:
description:
static:
response:
status: 200
- synopsis: Patch action group.
path: /_plugins/_security/api/actiongroups/{action_group}
method: PATCH
parameters:
action_group: test2
request_body:
payload:
op:
path:
value:
response:
status: 200
- synopsis: Delete action group.
path: /_plugins/_security/api/actiongroups/{action_group}
method: DELETE
parameters:
action_group: test2
response:
status: 200
epilogues:
- path: /_plugins/_security/api/actiongroups/{action_group}
method: DELETE
parameters:
action_group: test
status: [200, 404]
28 changes: 26 additions & 2 deletions tests/security/with-api-prefix/allowlist.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test allowlist endpoints.
prologues:

chapters:
epilogues:
- synopsis: Create an allowlist.
path: /_plugins/_security/api/allowlist
method: PUT
request_body:
payload:
config:
enabled: true,
requests: {}
response:
status: 200
- synopsis: Get an allowlist.
path: /_plugins/_security/api/allowlist
method: GET
response:
status: 200
- synopsis: Patch an allowlist.
path: /_plugins/_security/api/allowlist
method: PATCH
request_body:
payload:
op:
path:
value:
status: 200

48 changes: 46 additions & 2 deletions tests/security/with-api-prefix/audit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test audit endpoints.
prologues:

chapters:
epilogues:
- synopsis: Create an audit config.
path: /_plugins/_security/api/audit/config
method: PUT
request_body:
payload:
compliance:
enabled:
write_log_diffs:
read_watched_fields: {}
read_ignore_users: []
write_watched_indices: []
write_ignore_users: []
read_metadata_only:
write_metadata_only:
external_config:
internal_config:
enabled: true
audit:
ignore_users:
ignore_requests: []
disabled_rest_categories: []
disabled_transport_categories: []
log_request_body:
resolve_indices:
resolve_bulk_requests:
exclude_sensitive_headers:
enable_transport:
enable_rest:
response:
status: 200
- synopsis: Get an audit config.
path: /_plugins/_security/api/audit
method: GET
response:
status: 200
- synopsis: Patch an audit config.
path: /_plugins/_security/api/audit
method: PATCH
request_body:
payload:
op:
path:
value:
status: 200

6 changes: 0 additions & 6 deletions tests/security/with-api-prefix/authtoken.yaml

This file was deleted.

23 changes: 21 additions & 2 deletions tests/security/with-api-prefix/cache.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test cache endpoint.
prologues:

chapters:
epilogues:
- synopsis: Get cache.
path: /_plugins/_security/api/cache
method: GET
response:
status: 501
- synopsis: Create cache.
path: /_plugins/_security/api/cache
method: POST
response:
status: 501
- synopsis: Update cache.
path: /_plugins/_security/api/cache
method: PUT
response:
status: 501
- synopsis: Flush cache.
path: /_plugins/_security/api/cache
method: DELETE
response:
status: 200
57 changes: 55 additions & 2 deletions tests/security/with-api-prefix/internal_users.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test internal users endpoints.
prologues:

chapters:
epilogues:
- synopsis: Get internal users bulk.
path: /_plugins/_security/api/internalusers
method: GET
response:
status: 200
- synopsis: Patch internal users bulk.
path: /_plugins/_security/api/internalusers
method: PATCH
request_body:
payload:
op:
path:
value:
response:
status: 200
- synopsis: Create internal user.
path: /_plugins/_security/api/internalusers/{username}
method: PUT
parameters:
username: test2
request_body:
payload:
password: myWeakPassword123!
opendistro_security_roles: []
backend_roles: []
attributes: {}
response:
status: 200
- synopsis: Get internal user.
path: /_plugins/_security/api/internalusers/{username}
method: GET
parameters:
username: test
response:
status: 200
- synopsis: Patch internal user.
path: /_plugins/_security/api/internalusers/{username}
method: PATCH
parameters:
username: test
request_body:
payload:
op:
path:
value:
response:
status: 200
- synopsis: Delete internal user.
path: /_plugins/_security/api/internalusers/{username}
method: DELETE
parameters:
username: test
response:
status: 200
9 changes: 7 additions & 2 deletions tests/security/with-api-prefix/migrate.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test migrate endpoint.
prologues:

chapters:
epilogues:
- synopsis: Migrate v6 to v7 config.
path: /_plugins/_security/api/migrate
method: POST
response:
status: 200

61 changes: 59 additions & 2 deletions tests/security/with-api-prefix/nodesdn.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test nodesdn endpoints.
prologues:

chapters:
epilogues:
- synopsis: Get distinguished names.
path: /_plugins/_security/api/nodesdn
method: GET
parameters:
show_all: true
response:
status: 200
- synopsis: Patch distinguished names.
path: /_plugins/_security/api/nodesdn
method: PATCH
request_body:
payload:
op:
path:
value:
response:
status: 200
- synopsis: Create distinguished name.
path: /_plugins/_security/api/nodesdn/{cluster_name}
method: PUT
parameters:
cluster_name: test
request_body:
payload:
reserved:
hidden:
allowed_actions: []
type:
description:
static:
response:
status: 200
- synopsis: Get distinguished name.
path: /_plugins/_security/api/nodesdn/{cluster_name}
method: GET
parameters:
cluster_name: test
response:
status: 200
- synopsis: Patch distinguished name.
path: /_plugins/_security/api/nodesdn/{cluster_name}
method: PATCH
parameters:
cluster_name: test
request_body:
payload:
op:
path:
value:
response:
status: 200
- synopsis: Delete distinguished name.
path: /_plugins/_security/api/nodesdn/{cluster_name}
method: DELETE
parameters:
cluster_name: test
response:
status: 200
9 changes: 7 additions & 2 deletions tests/security/with-api-prefix/permissionsinfo.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test permissionsinfo endpoint.
prologues:

chapters:
epilogues:
- synopsis: Get evaluated permissions for currently logged in user.
path: /_plugins/_security/api/nodesdn
method: GET
response:
status: 200

Loading

0 comments on commit f65a6cf

Please sign in to comment.