コード例 #1
0
    def test_get_nameid_persistent(self):
        user = User(username='******', email='*****@*****.**')

        fully_qualified = NameIdBuilder.get_nameid_persistent(user.username, user=user, sp_entityid='sp_entity_id', idp_entityid='idp_entity_id')
        assert fully_qualified == 'idp_entity_id!sp_entity_id!86bb5037f0bf1a9cc7918296437fd560915c182316f23a3f4db480018eb1c71f'

        no_sp_idp_ids = NameIdBuilder.get_nameid_persistent(user.username, user=user)
        assert no_sp_idp_ids == '!!86bb5037f0bf1a9cc7918296437fd560915c182316f23a3f4db480018eb1c71f'
コード例 #2
0
    def test_request_unimplemented_nameid(self):
        user = User(username='******', email='*****@*****.**')

        requested_nameid_format = 'notimplemented_nameid_format'
        NameIdBuilder.format_mappings[requested_nameid_format] = 'nonexisting_method'

        with pytest.raises(NotImplementedError, match=f'{requested_nameid_format} has not been implemented NameIdBuilder methods'):
            NameIdBuilder.get_nameid(user.username, nameid_format=requested_nameid_format)
コード例 #3
0
    def test_get_nameid_email_invalid(self):
        user = User(username='******', email='*****@*****.**')

        with pytest.raises(
                Exception,
                message=
                f"user_id {user.username} does not contain the '@' symbol, so is not a valid NameID Email address format."
        ):
            NameIdBuilder.get_nameid_email(user.username)
コード例 #4
0
    def test_request_unmapped_nameid(self):
        user = User(username='******', email='*****@*****.**')
        requested_nameid_format = 'unmapped_nameid_format'

        with pytest.raises(
                NotImplementedError,
                match=
                f'{requested_nameid_format} has not been mapped in NameIdBuilder.format_mappings'
        ):
            NameIdBuilder.get_nameid(user.username,
                                     nameid_format=requested_nameid_format)
コード例 #5
0
    def test_get_nameid_persistent(self, sp_metadata_xml):
        user = User.objects.create(username='******', email='*****@*****.**')
        sp1 = ServiceProvider.objects.create(entity_id='sp_entity_id_1', local_metadata=sp_metadata_xml)
        sp2 = ServiceProvider.objects.create(entity_id='sp_entity_id_2', local_metadata=sp_metadata_xml)

        nameid_1 = NameIdBuilder.get_nameid_persistent(user.username, user=user, sp=sp1)
        nameid_2 = NameIdBuilder.get_nameid_persistent(user.username, user=user, sp=sp2)
        assert nameid_1 != nameid_2

        try:
            UUID(nameid_1, version=4)
            UUID(nameid_2, version=4)
        except ValueError:
            assert False
コード例 #6
0
    def test_get_nameid_email_valid(self):
        user = User(username='******', email='*****@*****.**')

        assert NameIdBuilder.get_nameid_email(user.email) == '*****@*****.**'
コード例 #7
0
    def test_get_nameid_transient(self):
        user = User(username='******', email='*****@*****.**')

        with pytest.raises(NotImplementedError):
            NameIdBuilder.get_nameid_transient(user.username)
コード例 #8
0
    def test_get_nameid_unspecified(self):
        user = User(username='******', email='*****@*****.**')

        assert NameIdBuilder.get_nameid_unspecified(user.username) == user.username
コード例 #9
0
    def test_get_nameid_opaque(self):
        user = User(username='******', email='*****@*****.**')

        assert NameIdBuilder._get_nameid_opaque(user.username) == 'b19cfa3a0f7cef07dc1dd1604cee0a49c57d0e1a4f1baa864ba1c7c2229b147f'