def test_csb_wrong_secret(): _token = "{}:{}".format(client_id, "pillow") token = as_unicode(base64.b64encode(as_bytes(_token))) authz_token = "Basic {}".format(token) with pytest.raises(AuthnFailure): ClientSecretBasic(endpoint_context).verify({}, authz_token)
def test_client_secret_basic(): _token = "{}:{}".format(client_id, client_secret) token = as_unicode(base64.b64encode(as_bytes(_token))) authz_token = "Basic {}".format(token) authn_info = ClientSecretBasic(endpoint_context).verify({}, authz_token) assert authn_info["client_id"] == client_id
class TestClientSecretBasic(): @pytest.fixture(autouse=True) def create_method(self): self.method = ClientSecretBasic(endpoint_context) def test_client_secret_basic(self): _token = "{}:{}".format(client_id, client_secret) token = as_unicode(base64.b64encode(as_bytes(_token))) authz_token = "Basic {}".format(token) assert self.method.is_usable(authorization_info=authz_token) authn_info = self.method.verify(authorization_info=authz_token) assert authn_info["client_id"] == client_id def test_wrong_type(self): assert self.method.is_usable(authorization_info="Foppa toffel") is False def test_csb_wrong_secret(self): _token = "{}:{}".format(client_id, "pillow") token = as_unicode(base64.b64encode(as_bytes(_token))) authz_token = "Basic {}".format(token) assert self.method.is_usable(authorization_info=authz_token) with pytest.raises(AuthnFailure): self.method.verify(authorization_info=authz_token)
def test_wrong_type(): with pytest.raises(AuthnFailure): ClientSecretBasic(endpoint_context).verify({}, "Foppa toffel")
def create_method(self): self.method = ClientSecretBasic(endpoint_context)