Skip to content

Commit 04e740e

Browse files
committed
Merge branch 'release-1.31.2' into merge
2 parents 689e862 + bf27fc6 commit 04e740e

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
LAB_OBO_PUBLIC_CLIENT_ID: ${{ secrets.LAB_OBO_PUBLIC_CLIENT_ID }}
2626

2727
# Derived from https://docs.github.com/en/actions/guides/building-and-testing-python#starting-with-the-python-workflow-template
28-
runs-on: ubuntu-22.04 # ubuntu-latest switched to 22.04 shortly after 2022-Nov-8
28+
runs-on: ubuntu-22.04
2929
strategy:
3030
matrix:
31-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", 3.13]
31+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
3232

3333
steps:
3434
- uses: actions/checkout@v4

msal/cloudshell.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ def _scope_to_resource(scope): # This is an experimental reasonable-effort appr
3232
if scope.startswith(a):
3333
return a
3434
u = urlparse(scope)
35+
if not u.scheme and not u.netloc: # Typically the "GUID/scope" case
36+
return u.path.split("/")[0]
3537
if u.scheme:
36-
return "{}://{}".format(u.scheme, u.netloc)
38+
trailer = ( # https://learn.microsoft.com/en-us/entra/identity-platform/scopes-oidc#trailing-slash-and-default
39+
"/" if u.path.startswith("//") else "")
40+
return "{}://{}{}".format(u.scheme, u.netloc, trailer)
3741
return scope # There is no much else we can do here
3842

3943

tests/test_cloudshell.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import unittest
2+
from msal.cloudshell import _scope_to_resource
3+
4+
class TestScopeToResource(unittest.TestCase):
5+
6+
def test_expected_behaviors(self):
7+
for scope, expected_resource in {
8+
"https://analysis.windows.net/powerbi/api/foo":
9+
"https://analysis.windows.net/powerbi/api", # A special case
10+
"https://pas.windows.net/CheckMyAccess/Linux/.default":
11+
"https://pas.windows.net/CheckMyAccess/Linux/.default", # Special case
12+
"https://double-slash.com//scope": "https://double-slash.com/",
13+
"https://single-slash.com/scope": "https://single-slash.com",
14+
"guid/some/scope": "guid",
15+
"6dae42f8-4368-4678-94ff-3960e28e3630/.default":
16+
# The real guid of AKS resource
17+
# https://learn.microsoft.com/en-us/azure/aks/kubelogin-authentication#how-to-use-kubelogin-with-aks
18+
"6dae42f8-4368-4678-94ff-3960e28e3630",
19+
}.items():
20+
self.assertEqual(_scope_to_resource(scope), expected_resource)
21+
22+
if __name__ == '__main__':
23+
unittest.main()

0 commit comments

Comments
 (0)