Skip to content

Commit

Permalink
Potentially fixed authorisation error when upgrading kubernetes (#1415)
Browse files Browse the repository at this point in the history
* Potentially fixed authorisation error when upgrading kubernetes

* Fixed broken test
  • Loading branch information
jamesstottmoj authored Dec 18, 2024
1 parent 336e1df commit 22ea8ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions controlpanel/api/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def __init__(self, id_token=None, use_cpanel_creds=False):
config = get_config()

if id_token:
config.api_key_prefix["authorization"] = "Bearer"
config.api_key["authorization"] = id_token
config.api_key = {"authorization": f"Bearer {id_token}"}

self.api_client = kubernetes.client.ApiClient(configuration=config)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ djproxy==2.3.6
elasticsearch-dsl==7.4.1
gunicorn==22.0.0
Jinja2==3.1.4
kubernetes==25.3.0
kubernetes==31.0.0
MarkupSafe==2.1.5
model-bakery==1.17.0
moto[all]==5.0.18
Expand Down
3 changes: 1 addition & 2 deletions tests/api/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def test_kubernetes_client_constructor_when_id_token_passed(k8s_config):
client = KubernetesClient(id_token=id_token)

config = client.api_client.configuration
assert config.api_key_prefix["authorization"] == "Bearer"
assert config.api_key["authorization"] == id_token
assert config.api_key == {"authorization": f"Bearer {id_token}"}


def test_kubernetes_client_constructor_when_use_cpanel_creds_true(k8s_config):
Expand Down

0 comments on commit 22ea8ec

Please sign in to comment.