diff --git a/devops/azure.py b/devops/azure.py index 1d57ac5..c8e9bdb 100644 --- a/devops/azure.py +++ b/devops/azure.py @@ -59,9 +59,9 @@ def get_token( def secret_credentials_auth( scope: str = DEVOPS_SCOPE, - tenant_id: str = os.environ.get("AZURE_TENANT_ID", ""), - client_id: str = os.environ.get("AZURE_CLIENT_ID", ""), - client_secret: str = os.environ.get("AZURE_CLIENT_SECRET") + tenant_id = os.environ.get("AZURE_TENANT_ID", ""), + client_id = os.environ.get("AZURE_CLIENT_ID", ""), + client_secret = os.environ.get("AZURE_CLIENT_SECRET") ) -> str: """ Authenticate using client credentials. Pass credentials via environment variables, @@ -92,8 +92,8 @@ def certificate_credentials_auth( # Wczytaj klucz prywatny (RSA) with open(pem_path, "rb") as f: pem = f.read() - key_pem = re.search(b"-----BEGIN (?:RSA )?PRIVATE KEY-----.*?END (?:RSA )?PRIVATE KEY-----", pem, re.S).group(0) - cert_pem = re.search(b"-----BEGIN CERTIFICATE-----.*?END CERTIFICATE-----", pem, re.S).group(0) + key_pem = re.search(b"-----BEGIN (?:RSA )?PRIVATE KEY-----.*?END (?:RSA )?PRIVATE KEY-----", pem, re.S).group(0) # type: ignore + cert_pem = re.search(b"-----BEGIN CERTIFICATE-----.*?END CERTIFICATE-----", pem, re.S).group(0) # type: ignore private_key = serialization.load_pem_private_key(key_pem, password=None) cert = x509.load_pem_x509_certificate(cert_pem) @@ -115,7 +115,7 @@ def certificate_credentials_auth( headers = {"x5t": x5t, "kid": x5t} - assertion = jwt.encode(claims, private_key, algorithm="RS256", headers=headers) + assertion = jwt.encode(claims, private_key, algorithm="RS256", headers=headers) # type: ignore data = { "grant_type": "client_credentials", diff --git a/harvester.py b/harvester.py index 60c7bde..888b1e0 100755 --- a/harvester.py +++ b/harvester.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 import requests -from sk.devops import Organization, Project, Repository, Item -from sk.azure import get_token +from devops.devops import Organization, Project, Repository, Item +from devops.azure import get_token org = Organization("https://dev.azure.com/mcovsandbox", token=get_token()) diff --git a/tests.py b/tests.py index 6823443..f1dea52 100755 --- a/tests.py +++ b/tests.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 import unittest import requests -from sk.devops import Organization, Repository, Project, Item -from sk.azure import get_token +from devops.devops import Organization, Repository, Project, Item +from devops.azure import get_token # Get the token outside the test class to speed up tests. # Each Unit test instantinates the class, so doing it here avoids repeated authentication.