Skip to content

Commit e6d7398

Browse files
committed
E2E test for Azure CLI's connectedk8s AT POP
1 parent 2488249 commit e6d7398

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/test_e2e.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
load_dotenv() # take environment variables from .env.
1111
except:
1212
pass
13-
13+
import base64
1414
import logging
1515
import os
1616
import json
@@ -708,6 +708,32 @@ def test_user_account(self):
708708
self._test_user_account()
709709

710710

711+
def _data_for_pop(key):
712+
raw_req_cnf = json.dumps({"kid": key, "xms_ksl": "sw"})
713+
return { # Sampled from Azure CLI's plugin connectedk8s
714+
'token_type': 'pop',
715+
'key_id': key,
716+
"req_cnf": base64.urlsafe_b64encode(raw_req_cnf.encode('utf-8')).decode('utf-8').rstrip('='),
717+
# Note: Sending raw_req_cnf without base64 encoding would result in an http 500 error
718+
} # See also https://github.com/Azure/azure-cli-extensions/blob/main/src/connectedk8s/azext_connectedk8s/_clientproxyutils.py#L86-L92
719+
720+
721+
class AtPopWithExternalKeyTestCase(PopWithExternalKeyTestCase):
722+
EXPECTED_TOKEN_TYPE = "pop"
723+
DATA1 = _data_for_pop('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA-AAAAAAAA') # Fake key with a certain format and length
724+
DATA2 = _data_for_pop('BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB-BBBBBBBB') # Fake key with a certain format and length
725+
SCOPE = [
726+
'6256c85f-0aad-4d50-b960-e6e9b21efe35/.default', # Azure CLI's connectedk8s plugin uses this
727+
# https://github.com/Azure/azure-cli-extensions/pull/4468/files#diff-a47efa3186c7eb4f1176e07d0b858ead0bf4a58bfd51e448ee3607a5b4ef47f6R116
728+
]
729+
730+
def test_service_principal(self):
731+
self._test_service_principal()
732+
733+
def test_user_account(self):
734+
self._test_user_account()
735+
736+
711737
class WorldWideTestCase(LabBasedTestCase):
712738

713739
def test_aad_managed_user(self): # Pure cloud

0 commit comments

Comments
 (0)