035a5ce
%bcond tests 1
43d2df1
# For testing/development purposes, it could make sense to do a mock build with
43d2df1
# --with network_tests --enable-network.
035a5ce
%bcond network_tests 0
eda163b
662fe36
Name:           python-msal
Packit dd2eaec
Version:        1.28.0
59bf687
Release:        %autorelease
44cd49f
Summary:        Microsoft Authentication Library (MSAL) for Python
44cd49f
ed3e3f9
# SPDX
44cd49f
License:        MIT
662fe36
URL:            https://github.com/AzureAD/microsoft-authentication-library-for-python
c129172
Source:         %{url}/archive/%{version}/microsoft-authentication-library-for-python-%{version}.tar.gz
59bf687
44cd49f
BuildArch:      noarch
44cd49f
008e520
BuildRequires:  python3-devel
59bf687
59bf687
%if %{with tests}
59bf687
BuildRequires:  python3dist(pytest)
59bf687
%endif
59bf687
59bf687
%global _description %{expand:
e1789a0
The Microsoft Authentication Library for Python enables applications to
e1789a0
integrate with the Microsoft identity platform. It allows you to sign in users
e1789a0
or apps with Microsoft identities (Azure AD, Microsoft Accounts and Azure AD
e1789a0
B2C accounts) and obtain tokens to call Microsoft APIs such as Microsoft Graph
e1789a0
or your own APIs registered with the Microsoft identity platform. It is built
e1789a0
using industry standard OAuth2 and OpenID Connect protocols.}
59bf687
59bf687
%description %{_description}
44cd49f
44cd49f
662fe36
%package -n python3-msal
44cd49f
Summary:        %{summary}
662fe36
%description -n python3-msal %{_description}
44cd49f
44cd49f
662fe36
%pyproject_extras_subpkg -n python3-msal broker
ad3bb72
ad3bb72
44cd49f
%prep
c129172
%autosetup -n microsoft-authentication-library-for-python-%{version}
c129172
c129172
# - We can’t generate BR’s from a requirements file with “-e .” in it.
c129172
# - We don’t need or want to run benchmarks (tests/test_benchmark.py), so don’t
c129172
#   generate benchmarking dependencies.
c129172
# - We don’t need python-dotenv if we aren’t running network tests (and on some
c129172
#   older releases, it is too old.)
c129172
sed -r \
c129172
    -e 's/^\-e/# &/' \
c129172
    -e 's/^(pytest-benchmark|perf_baseline)\b/# &/' \
c129172
%if %{without network_tests} || 0%{?fc37} || 0%{?el9}
c129172
    -e 's/^(python-dotenv)\b/# &/' \
c129172
%endif
c129172
    requirements.txt | tee requirements-filtered.txt
44cd49f
59bf687
59bf687
%generate_buildrequires
c129172
%pyproject_buildrequires -r requirements-filtered.txt
44cd49f
44cd49f
44cd49f
%build
59bf687
%pyproject_wheel
44cd49f
44cd49f
44cd49f
%install
59bf687
%pyproject_install
3c5b54b
%pyproject_save_files -l msal
d421ba0
d421ba0
d421ba0
%check
372d814
%if %{with tests}
43d2df1
%if %{without network_tests}
43d2df1
# All of the following require network access:
43d2df1
k="${k-}${k+ and }not TestClientApplicationAcquireTokenSilentErrorBehaviors"
43d2df1
k="${k-}${k+ and }not TestClientApplicationAcquireTokenSilentFociBehaviors"
43d2df1
k="${k-}${k+ and }not TestClientApplicationForAuthorityMigration"
43d2df1
k="${k-}${k+ and }not TestTelemetryMaintainingOfflineState"
43d2df1
k="${k-}${k+ and }not TestClientApplicationWillGroupAccounts"
43d2df1
k="${k-}${k+ and }not TestClientCredentialGrant"
43d2df1
k="${k-}${k+ and }not TestScopeDecoration"
43d2df1
k="${k-}${k+ and }not (TestAuthority and test_unknown_host_wont_pass_instance_discovery)"
43d2df1
k="${k-}${k+ and }not (TestAuthority and test_wellknown_host_and_tenant)"
43d2df1
k="${k-}${k+ and }not (TestAuthority and test_wellknown_host_and_tenant_using_new_authority_builder)"
43d2df1
k="${k-}${k+ and }not TestAuthorityInternalHelperUserRealmDiscovery"
43d2df1
k="${k-}${k+ and }not TestCcsRoutingInfoTestCase"
43d2df1
k="${k-}${k+ and }not TestApplicationForRefreshInBehaviors"
43d2df1
k="${k-}${k+ and }not TestTelemetryOnClientApplication"
43d2df1
k="${k-}${k+ and }not TestTelemetryOnPublicClientApplication"
43d2df1
k="${k-}${k+ and }not TestTelemetryOnConfidentialClientApplication"
Packit dd2eaec
k="${k-}${k+ and }not TestRemoveTokensForClient"
c129172
# Without network access, these even error during test collection!
c129172
ignore="${ignore-} --ignore=tests/test_cryptography.py"
43d2df1
ignore="${ignore-} --ignore=tests/test_e2e.py"
43d2df1
%else
43d2df1
# This test requires browser interaction.
43d2df1
k="${k-}${k+ and }not (SshCertTestCase and test_ssh_cert_for_user_should_work_with_any_account)"
c129172
# Obviously, the python-cryptography package may sometimes lag upstream.
c129172
k="${k-}${k+ and }not (CryptographyTestCase and test_should_be_run_with_latest_version_of_cryptography)"
c129172
%if 0%{?fc37} || 0%{?epel9}
c129172
# python-dotenv is too old
c129172
ignore="${ignore-} --ignore=tests/test_e2e.py"
43d2df1
%endif
c129172
%endif
c129172
c129172
# We don’t need or want to run benchmarks.
c129172
ignore="${ignore-} --ignore=tests/test_benchmark.py"
43d2df1
43d2df1
%pytest --disable-warnings tests ${ignore-} -k "${k-}" -v
372d814
372d814
%else
372d814
# The msal.broker module requires pymsalruntime, which is provided on Windows
372d814
# when the broker extra is installed, but which is not available at all
372d814
# otherwise.
372d814
%pyproject_check_import -e msal.broker
eda163b
%endif
d421ba0
44cd49f
662fe36
%files -n python3-msal -f %{pyproject_files}
24c895e
%doc README.md
d421ba0
d421ba0
44cd49f
%changelog
59bf687
%autochangelog