mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
fix: restore 2 tests
This commit is contained in:
@@ -579,3 +579,44 @@ class TestM365Provider:
|
||||
"M365 provider requires AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID, M365_USER and M365_ENCRYPTED_PASSWORD environment variables to be set when using --env-auth"
|
||||
in str(exception.value)
|
||||
)
|
||||
|
||||
def test_setup_powershell_valid_credentials(self):
|
||||
credentials_dict = {
|
||||
"user": "test@example.com",
|
||||
"encrypted_password": "test_password",
|
||||
"client_id": "test_client_id",
|
||||
"tenant_id": "test_tenant_id",
|
||||
"client_secret": "test_client_secret",
|
||||
}
|
||||
|
||||
with patch(
|
||||
"prowler.providers.m365.lib.powershell.m365_powershell.M365PowerShell.test_credentials",
|
||||
return_value=True,
|
||||
):
|
||||
result = M365Provider.setup_powershell(
|
||||
env_auth=False, m365_credentials=credentials_dict
|
||||
)
|
||||
|
||||
assert result.user == credentials_dict["user"]
|
||||
assert result.passwd == credentials_dict["encrypted_password"]
|
||||
|
||||
def test_setup_powershell_invalid_env_credentials(self):
|
||||
credentials = None
|
||||
|
||||
with patch(
|
||||
"prowler.providers.m365.lib.powershell.m365_powershell.M365PowerShell"
|
||||
) as mock_powershell:
|
||||
mock_session = MagicMock()
|
||||
mock_session.test_credentials.return_value = False
|
||||
mock_powershell.return_value = mock_session
|
||||
|
||||
with pytest.raises(M365MissingEnvironmentCredentialsError) as exc_info:
|
||||
M365Provider.setup_powershell(
|
||||
env_auth=True, m365_credentials=credentials
|
||||
)
|
||||
|
||||
assert (
|
||||
"Missing M365_USER or M365_ENCRYPTED_PASSWORD environment variables required for credentials authentication"
|
||||
in str(exc_info.value)
|
||||
)
|
||||
mock_session.test_credentials.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user