def test_creating_directory_with_defined_password_policy(self):
        ds = MagicMock()
        ds.create_resource.return_value = {}

        dl = DirectoryList(
            client=MagicMock(data_store=ds, BASE_URL='http://example.com'),
            href='directories')

        dl.create({
            'name': 'Foo',
            'description': 'Desc',
            'password_policy': {
                'reset_email_status':
                    PasswordPolicy.RESET_EMAIL_STATUS_ENABLED,
                'reset_success_email_status':
                    PasswordPolicy.RESET_EMAIL_STATUS_ENABLED,
                'reset_token_ttl': 32
                }
        })

        ds.create_resource.assert_called_once_with(
            'http://example.com/directories', {
                'passwordPolicy': {
                    'resetSuccessEmailStatus': 'ENABLED',
                    'resetEmailStatus': 'ENABLED',
                    'resetTokenTtl': 32
                },
                'description': 'Desc',
                'name': 'Foo',
            }, params={})
    def test_creating_provider_directory_passes_provider_info(self):
        ds = MagicMock()
        ds.create_resource.return_value = {}

        dl = DirectoryList(
            client=MagicMock(data_store=ds, BASE_URL='http://example.com'),
            href='directories')

        dl.create({
            'name': 'Foo',
            'description': 'Desc',
            'provider': {
                'client_id': 'ID',
                'client_secret': 'SECRET',
                'redirect_uri': 'SOME_URL',
                'provider_id': 'myprovider'
            }
        })

        ds.create_resource.assert_called_once_with(
            'http://example.com/directories', {
                'description': 'Desc',
                'name': 'Foo',
                'provider': {
                    'clientSecret': 'SECRET',
                    'providerId': 'myprovider',
                    'redirectUri': 'SOME_URL',
                    'clientId': 'ID'
                }
            }, params={})
Ejemplo n.º 3
0
    def test_creating_provider_directory_passes_provider_info(self):
        ds = MagicMock()
        ds.create_resource.return_value = {}

        dl = DirectoryList(
            client=MagicMock(data_store=ds, BASE_URL='http://example.com'),
            href='directories')

        dl.create({
            'name': 'Foo',
            'description': 'Desc',
            'provider': {
                'client_id': 'ID',
                'client_secret': 'SECRET',
                'redirect_uri': 'SOME_URL',
                'provider_id': 'myprovider'
            }
        })

        ds.create_resource.assert_called_once_with(
            'http://example.com/directories', {
                'description': 'Desc',
                'name': 'Foo',
                'provider': {
                    'clientSecret': 'SECRET',
                    'providerId': 'myprovider',
                    'redirectUri': 'SOME_URL',
                    'clientId': 'ID'
                }
            }, params={})
Ejemplo n.º 4
0
    def test_creating_directory_with_defined_password_policy(self):
        ds = MagicMock()
        ds.create_resource.return_value = {}

        dl = DirectoryList(client=MagicMock(data_store=ds,
                                            BASE_URL='http://example.com'),
                           href='directories')

        dl.create({
            'name': 'Foo',
            'description': 'Desc',
            'password_policy': {
                'reset_email_status':
                PasswordPolicy.RESET_EMAIL_STATUS_ENABLED,
                'reset_success_email_status':
                PasswordPolicy.RESET_EMAIL_STATUS_ENABLED,
                'reset_token_ttl': 32
            }
        })

        ds.create_resource.assert_called_once_with(
            'http://example.com/directories', {
                'passwordPolicy': {
                    'resetSuccessEmailStatus': 'ENABLED',
                    'resetEmailStatus': 'ENABLED',
                    'resetTokenTtl': 32
                },
                'description': 'Desc',
                'name': 'Foo',
            },
            params={})
Ejemplo n.º 5
0
    def test_modify_directory_provider(self):
        ds = MagicMock()
        ds.create_resource.return_value = {
            'name': 'Foo',
            'description': 'Desc',
            'provider': {
                'href': 'provider',
                'client_id': 'ID',
                'client_secret': 'SECRET',
                'redirect_uri': 'SOME_URL',
                'provider_id': 'myprovider'
            }
        }
        ds.update_resource.return_value = {}

        dl = DirectoryList(
            client=MagicMock(data_store=ds, BASE_URL='http://example.com'),
            href='directories')

        d = dl.create({
            'name': 'Foo',
            'description': 'Desc',
            'provider': {
                'client_id': 'ID',
                'client_secret': 'SECRET',
                'redirect_uri': 'SOME_URL',
                'provider_id': 'myprovider'
            }
        })

        d.provider.redirect_uri = 'SOME_OTHER_URL'
        d.provider.save()

        ds.update_resource.assert_called_once_with(
            'provider',
            {
                'clientSecret': 'SECRET',
                'providerId': 'myprovider',
                'redirectUri': 'SOME_OTHER_URL',
                'clientId': 'ID'
            })