Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Mar 3, 2021
1 parent cf5b9e1 commit 94226a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
10 changes: 5 additions & 5 deletions tests/handlers/test_cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_map_cas_user_to_user(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "redirect_uri", None, new_user=True
"@test_user:test", "cas", request, "redirect_uri", None, new_user=True
)

def test_map_cas_user_to_existing_user(self):
Expand All @@ -89,7 +89,7 @@ def test_map_cas_user_to_existing_user(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "redirect_uri", None, new_user=False
"@test_user:test", "cas", request, "redirect_uri", None, new_user=False
)

# Subsequent calls should map to the same mxid.
Expand All @@ -98,7 +98,7 @@ def test_map_cas_user_to_existing_user(self):
self.handler._handle_cas_response(request, cas_response, "redirect_uri", "")
)
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "redirect_uri", None, new_user=False
"@test_user:test", "cas", request, "redirect_uri", None, new_user=False
)

def test_map_cas_user_to_invalid_localpart(self):
Expand All @@ -116,7 +116,7 @@ def test_map_cas_user_to_invalid_localpart(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@f=c3=b6=c3=b6:test", request, "redirect_uri", None, new_user=True
"@f=c3=b6=c3=b6:test", "cas", request, "redirect_uri", None, new_user=True
)

@override_config(
Expand Down Expand Up @@ -160,7 +160,7 @@ def test_required_attributes(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "redirect_uri", None, new_user=True
"@test_user:test", "cas", request, "redirect_uri", None, new_user=True
)


Expand Down
19 changes: 10 additions & 9 deletions tests/handlers/test_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def test_callback(self):
self.get_success(self.handler.handle_oidc_callback(request))

auth_handler.complete_sso_login.assert_called_once_with(
expected_user_id, request, client_redirect_url, None, new_user=True
expected_user_id, "oidc", request, client_redirect_url, None, new_user=True
)
self.provider._exchange_code.assert_called_once_with(code)
self.provider._parse_id_token.assert_called_once_with(token, nonce=nonce)
Expand Down Expand Up @@ -460,7 +460,7 @@ def test_callback(self):
self.get_success(self.handler.handle_oidc_callback(request))

auth_handler.complete_sso_login.assert_called_once_with(
expected_user_id, request, client_redirect_url, None, new_user=False
expected_user_id, "oidc", request, client_redirect_url, None, new_user=False
)
self.provider._exchange_code.assert_called_once_with(code)
self.provider._parse_id_token.assert_not_called()
Expand Down Expand Up @@ -646,6 +646,7 @@ def test_extra_attributes(self):

auth_handler.complete_sso_login.assert_called_once_with(
"@foo:test",
"oidc",
request,
client_redirect_url,
{"phone": "1234567"},
Expand All @@ -663,7 +664,7 @@ def test_map_userinfo_to_user(self):
}
self.get_success(_make_callback_with_userinfo(self.hs, userinfo))
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", ANY, ANY, None, new_user=True
"@test_user:test", "oidc", ANY, ANY, None, new_user=True
)
auth_handler.complete_sso_login.reset_mock()

Expand All @@ -674,7 +675,7 @@ def test_map_userinfo_to_user(self):
}
self.get_success(_make_callback_with_userinfo(self.hs, userinfo))
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user_2:test", ANY, ANY, None, new_user=True
"@test_user_2:test", "oidc", ANY, ANY, None, new_user=True
)
auth_handler.complete_sso_login.reset_mock()

Expand Down Expand Up @@ -711,14 +712,14 @@ def test_map_userinfo_to_existing_user(self):
}
self.get_success(_make_callback_with_userinfo(self.hs, userinfo))
auth_handler.complete_sso_login.assert_called_once_with(
user.to_string(), ANY, ANY, None, new_user=False
user.to_string(), "oidc", ANY, ANY, None, new_user=False
)
auth_handler.complete_sso_login.reset_mock()

# Subsequent calls should map to the same mxid.
self.get_success(_make_callback_with_userinfo(self.hs, userinfo))
auth_handler.complete_sso_login.assert_called_once_with(
user.to_string(), ANY, ANY, None, new_user=False
user.to_string(), "oidc", ANY, ANY, None, new_user=False
)
auth_handler.complete_sso_login.reset_mock()

Expand All @@ -733,7 +734,7 @@ def test_map_userinfo_to_existing_user(self):
}
self.get_success(_make_callback_with_userinfo(self.hs, userinfo))
auth_handler.complete_sso_login.assert_called_once_with(
user.to_string(), ANY, ANY, None, new_user=False
user.to_string(), "oidc", ANY, ANY, None, new_user=False
)
auth_handler.complete_sso_login.reset_mock()

Expand Down Expand Up @@ -769,7 +770,7 @@ def test_map_userinfo_to_existing_user(self):

self.get_success(_make_callback_with_userinfo(self.hs, userinfo))
auth_handler.complete_sso_login.assert_called_once_with(
"@TEST_USER_2:test", ANY, ANY, None, new_user=False
"@TEST_USER_2:test", "oidc", ANY, ANY, None, new_user=False
)

def test_map_userinfo_to_invalid_localpart(self):
Expand Down Expand Up @@ -805,7 +806,7 @@ def test_map_userinfo_to_user_retries(self):

# test_user is already taken, so test_user1 gets registered instead.
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user1:test", ANY, ANY, None, new_user=True
"@test_user1:test", "oidc", ANY, ANY, None, new_user=True
)
auth_handler.complete_sso_login.reset_mock()

Expand Down
10 changes: 5 additions & 5 deletions tests/handlers/test_saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_map_saml_response_to_user(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "redirect_uri", None, new_user=True
"@test_user:test", "saml", request, "redirect_uri", None, new_user=True
)

@override_config({"saml2_config": {"grandfathered_mxid_source_attribute": "mxid"}})
Expand All @@ -157,7 +157,7 @@ def test_map_saml_response_to_existing_user(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "", None, new_user=False
"@test_user:test", "saml", request, "", None, new_user=False
)

# Subsequent calls should map to the same mxid.
Expand All @@ -166,7 +166,7 @@ def test_map_saml_response_to_existing_user(self):
self.handler._handle_authn_response(request, saml_response, "")
)
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "", None, new_user=False
"@test_user:test", "saml", request, "", None, new_user=False
)

def test_map_saml_response_to_invalid_localpart(self):
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_map_saml_response_to_user_retries(self):

# test_user is already taken, so test_user1 gets registered instead.
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user1:test", request, "", None, new_user=True
"@test_user1:test", "saml", request, "", None, new_user=True
)
auth_handler.complete_sso_login.reset_mock()

Expand Down Expand Up @@ -310,7 +310,7 @@ def test_attribute_requirements(self):

# check that the auth handler got called as expected
auth_handler.complete_sso_login.assert_called_once_with(
"@test_user:test", request, "redirect_uri", None, new_user=True
"@test_user:test", "saml", request, "redirect_uri", None, new_user=True
)


Expand Down

0 comments on commit 94226a4

Please sign in to comment.