Exemplo n.º 1
0
    def test_valid_remote_metadata_url(self, mock_get, settings,
                                       sp_metadata_xml, use_tz, tzinfo):
        settings.USE_TZ = use_tz
        mock_get.return_value = mock.Mock(status_code=200,
                                          text=sp_metadata_xml)
        form = ServiceProviderAdminForm({
            'entity_id':
            'entity-id',
            '_processor':
            'djangosaml2idp.processors.BaseProcessor',
            'remote_metadata_url':
            'https://ok',
            '_attribute_mapping':
            json.dumps({
                'name': 'fullName',
                'email': 'emailAddress',
                'other_setting': 'otherSetting',
                'random_method': 'randomMethodTest'
            }),
        })

        assert form.is_valid() is True
        instance = form.save()
        assert instance.remote_metadata_url == 'https://ok'
        assert instance.local_metadata == sp_metadata_xml
        assert instance.metadata_expiration_dt == datetime.datetime(
            2099, 2, 14, 17, 43, 34, tzinfo=tzinfo)
Exemplo n.º 2
0
    def test_valid_local_metadata(self, settings, sp_metadata_xml, use_tz, tzinfo):
        settings.USE_TZ = use_tz
        form = ServiceProviderAdminForm({
            'entity_id': 'entity-id',
            '_processor': 'djangosaml2idp.processors.BaseProcessor',
            'local_metadata': sp_metadata_xml,
            '_attribute_mapping': json.dumps({
                'name': 'fullName',
                'email': 'emailAddress',
                'other_setting': 'otherSetting',
                'random_method': 'randomMethodTest'
            }),
        })

        assert form.is_valid() is True
        instance = form.save()
        assert instance.remote_metadata_url == ''
        assert instance.local_metadata == sp_metadata_xml
        assert instance.metadata_expiration_dt == datetime.datetime(2021, 2, 14, 17, 43, 34, tzinfo=tzinfo)