Skip to content

Commit

Permalink
Add ondelete cascade to user credential group foreign keys and update…
Browse files Browse the repository at this point in the history
… integration tests
  • Loading branch information
arash77 committed Jan 3, 2025
1 parent e346936 commit be6eb75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11646,7 +11646,7 @@ class Variable(Base):

id: Mapped[int] = mapped_column(primary_key=True)
user_credential_group_id: Mapped[int] = mapped_column(
ForeignKey("user_credentials_group.id"), index=True, nullable=False
ForeignKey("user_credentials_group.id", ondelete="CASCADE"), index=True, nullable=False
)
name: Mapped[str] = mapped_column(nullable=False)
value: Mapped[str] = mapped_column(nullable=False)
Expand All @@ -11663,7 +11663,7 @@ class Secret(Base):

id: Mapped[int] = mapped_column(primary_key=True)
user_credential_group_id: Mapped[int] = mapped_column(
ForeignKey("user_credentials_group.id"), index=True, nullable=False
ForeignKey("user_credentials_group.id", ondelete="CASCADE"), index=True, nullable=False
)
name: Mapped[str] = mapped_column(nullable=False)
already_set: Mapped[bool] = mapped_column(nullable=False, default=False)
Expand Down
13 changes: 5 additions & 8 deletions test/integration/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ def test_provide_credential(self):
assert created_user_credentials[0]["current_group_name"] == "default"

def test_list_user_credentials(self):
list_user_credentials = self._list_user_credentials()
response = self._get("/api/users/current/credentials")
self._assert_status_code_is(response, 200)
list_user_credentials = response.json()
assert len(list_user_credentials) > 0

def test_delete_service_credentials(self):
list_user_credentials = self._list_user_credentials()
user_credentials_id = list_user_credentials[0]["id"]
created_user_credentials = self._populate_user_credentials()
user_credentials_id = created_user_credentials[0]["id"]
response = self._delete(f"/api/users/current/credentials/{user_credentials_id}")
self._assert_status_code_is(response, 204)

Expand Down Expand Up @@ -72,8 +74,3 @@ def _populate_user_credentials(self):
response = self._post("/api/users/current/credentials", data=payload, json=True)
self._assert_status_code_is(response, 200)
return response.json()

def _list_user_credentials(self):
response = self._get("/api/users/current/credentials")
self._assert_status_code_is(response, 200)
return response.json()

0 comments on commit be6eb75

Please sign in to comment.