Skip to content

Commit

Permalink
Merge pull request #187 from canonical/pin-kratos-1.0.0
Browse files Browse the repository at this point in the history
Downgrade Kratos
  • Loading branch information
nsklikas authored May 1, 2024
2 parents ec3e909 + bfadb5a commit b214b9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resources:
oci-image:
type: oci-image
description: Kratos oci-image
upstream-source: ghcr.io/canonical/kratos:1.1.0
upstream-source: ghcr.io/canonical/kratos:1.0.0
requires:
pg-database:
interface: postgresql_client
Expand Down
3 changes: 1 addition & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,7 @@ def _on_delete_identity_action(self, event: ActionEvent) -> None:

if email:
identity = self.kratos.get_identity_from_email(email)
identity_id = identity.get("id")
if not identity_id:
if not identity:
event.fail("Couldn't retrieve identity_id from email.")
return

Expand Down
4 changes: 1 addition & 3 deletions src/kratos.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ def list_identities(self) -> List:

# TODO: Consider reading from the stream instead of waiting for output
cmd_output = json.loads(self._run_cmd(cmd))
identities = cmd_output.get("identities")
logger.info("Successfully fetched all identities")

return identities
return cmd_output

def get_identity_from_email(self, email: str) -> Optional[Dict]:
"""Get an identity using an email.
Expand Down
15 changes: 3 additions & 12 deletions tests/unit/test_kratos.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ def test_delete_identity(
def test_list_identities(
kratos_api: KratosAPI, kratos_identity_json: Dict, mocked_kratos_process: MagicMock
) -> None:
mocked_kratos_process.wait_output.return_value = (
json.dumps(dict(identities=[kratos_identity_json])),
None,
)
mocked_kratos_process.wait_output.return_value = (json.dumps([kratos_identity_json]), None)

kratos_api.list_identities()

Expand All @@ -153,10 +150,7 @@ def test_list_identities(
def test_get_identity_from_email(
kratos_api: KratosAPI, kratos_identity_json: Dict, mocked_kratos_process: MagicMock
) -> None:
mocked_kratos_process.wait_output.return_value = (
json.dumps(dict(identities=[kratos_identity_json])),
None,
)
mocked_kratos_process.wait_output.return_value = (json.dumps([kratos_identity_json]), None)

identity = kratos_api.get_identity_from_email(kratos_identity_json["traits"]["email"])

Expand All @@ -175,10 +169,7 @@ def test_get_identity_from_email(
def test_get_identity_from_email_with_wrong_mail(
kratos_api: KratosAPI, kratos_identity_json: Dict, mocked_kratos_process: MagicMock
) -> None:
mocked_kratos_process.wait_output.return_value = (
json.dumps(dict(identities=[kratos_identity_json])),
None,
)
mocked_kratos_process.wait_output.return_value = (json.dumps([kratos_identity_json]), None)

identity = kratos_api.get_identity_from_email("mail")

Expand Down

0 comments on commit b214b9b

Please sign in to comment.