Skip to content

Commit

Permalink
Add integration test for adding a new group to user credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Jan 15, 2025
1 parent 1fc1eb7 commit 8fbd065
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/integration/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,46 @@ def test_delete_not_existing_credentials(self):
response = self._delete("/api/users/current/credentials/f2db41e1fa331b3e/f2db41e1fa331b3e")
self._assert_status_code_is(response, 400)

def test_add_group_to_credentials(self):
self._populate_user_credentials()
new_group_name = "new_group"
payload = {
"source_type": "tool",
"source_id": "test_tool",
"credentials": [
{
"reference": "test_service",
"current_group": new_group_name,
"groups": [
{
"name": "default",
"variables": [{"name": "server", "value": "http://localhost:8080"}],
"secrets": [
{"name": "username", "value": "user"},
{"name": "password", "value": "pass"},
{"name": "token", "value": "key"},
],
},
{
"name": new_group_name,
"variables": [{"name": "server", "value": "http://localhost:8080/new"}],
"secrets": [
{"name": "username", "value": "user_new"},
{"name": "password", "value": "pass_new"},
{"name": "token", "value": "key_new"},
],
},
],
},
],
}
response = self._post("/api/users/current/credentials", data=payload, json=True)
self._assert_status_code_is(response, 200)
updated_user_credentials = response.json()
assert len(updated_user_credentials) == 1
assert updated_user_credentials[0]["current_group_name"] == new_group_name
assert len(updated_user_credentials[0]["groups"]) == 2

def _populate_user_credentials(self):
payload = {
"source_type": "tool",
Expand Down

0 comments on commit 8fbd065

Please sign in to comment.