Skip to content

Commit

Permalink
Merge pull request #118 from canonical/KF-4400-fix-waiting-error
Browse files Browse the repository at this point in the history
Fix waiting for pod startup
  • Loading branch information
misohu authored Nov 24, 2023
2 parents 7bbc2a3 + 6ed7b8e commit 9c7a4f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, *args):
self.on.leader_elected,
self.on.upgrade_charm,
self.on.config_changed,
self.on.oidc_authservice_pebble_ready,
self.on["ingress"].relation_changed,
self.on["ingress-auth"].relation_changed,
self.on["oidc-client"].relation_changed,
Expand Down
21 changes: 20 additions & 1 deletion tests/unit/test_operator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
from unittest.mock import patch
from unittest.mock import MagicMock, patch

import pytest
import yaml
Expand Down Expand Up @@ -136,3 +136,22 @@ def test_session_store(harness):
assert (
plan.services["oidc-authservice"].environment["OIDC_STATE_STORE_PATH"] == "oidc_state.db"
)


@patch("charm.KubernetesServicePatch", lambda x, y: None)
@patch("charm.update_layer", MagicMock())
def test_pebble_ready_hook_handled(harness: Harness):
"""
Test if we handle oidc_authservice_pebble_ready hook. This test fails if we don't.
"""
harness.set_leader(True)
harness.begin()
harness.charm._check_public_url = MagicMock()
harness.charm._get_interfaces = MagicMock()
harness.charm._check_secret = MagicMock()
harness.charm._send_info = MagicMock()
harness.charm._configure_mesh = MagicMock()

harness.charm.on.oidc_authservice_pebble_ready.emit(harness.charm)

assert isinstance(harness.charm.model.unit.status, ActiveStatus)

0 comments on commit 9c7a4f5

Please sign in to comment.