How to use the hvac.api.auth_methods.Ldap function in hvac

To help you get started, we’ve selected a few hvac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
'request_id': '89144def-b675-4c8a-590c-4f2ad4f1fae7',
            'data': {
                'keys': ['cats']
            },
            'renewable': False
        }
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/groups'.format(
            mount_point=mount_point,
        )
        requests_mocker.register_uri(
            method='LIST',
            url=mock_url,
            status_code=expected_status_code,
            json=mock_response,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.list_groups(
            mount_point=mount_point,
        )
        self.assertEqual(
            first=mock_response,
            second=response,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
'groupattr': '',
                'upndomain': '',
                'discoverdn': False
            },
            'renewable': False
        }
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/config'.format(
            mount_point=mount_point,
        )
        requests_mocker.register_uri(
            method='GET',
            url=mock_url,
            status_code=expected_status_code,
            json=mock_response,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.read_configuration(
            mount_point=mount_point,
        )
        self.assertEqual(
            first=mock_response,
            second=response,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
'data': {
                'policies': []
            },
            'renewable': False
        }
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/groups/{name}'.format(
            mount_point=mount_point,
            name=group_name,
        )
        requests_mocker.register_uri(
            method='GET',
            url=mock_url,
            status_code=expected_status_code,
            json=mock_response,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.read_group(
            name=group_name,
            mount_point=mount_point,
        )
        self.assertEqual(
            first=mock_response,
            second=response,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
'lease_duration': 0,
            'request_id': 'c7a85e6c-fb1f-1d97-83a1-63746cb65551',
            'data': {},
            'renewable': False
        }
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/login/{username}'.format(
            mount_point=mount_point,
            username=username,
        )
        requests_mocker.register_uri(
            method='POST',
            url=mock_url,
            status_code=expected_status_code,
            json=mock_response,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.login(
            mount_point=mount_point,
            username=username,
            password='averynicepassword'
        )
        self.assertEqual(
            first=mock_response,
            second=response,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
def test_delete_user(self, test_label, mount_point, requests_mocker):
        expected_status_code = 204
        username = 'somedude'
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/users/{username}'.format(
            mount_point=mount_point,
            username=username,
        )
        requests_mocker.register_uri(
            method='DELETE',
            url=mock_url,
            status_code=expected_status_code,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.delete_user(
            username=username,
            mount_point=mount_point,
        )
        self.assertEqual(
            first=expected_status_code,
            second=response.status_code,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
def test_create_or_update_user(self, test_label, mount_point, requests_mocker):
        expected_status_code = 204
        username = 'somedude'
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/users/{name}'.format(
            mount_point=mount_point,
            name=username,
        )
        requests_mocker.register_uri(
            method='POST',
            url=mock_url,
            status_code=expected_status_code,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.create_or_update_user(
            username=username,
            mount_point=mount_point,
        )
        self.assertEqual(
            first=expected_status_code,
            second=response.status_code,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
'policies': [],
                'groups': ''
            },
            'renewable': False
        }
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/users/{username}'.format(
            mount_point=mount_point,
            username=username,
        )
        requests_mocker.register_uri(
            method='GET',
            url=mock_url,
            status_code=expected_status_code,
            json=mock_response,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.read_user(
            mount_point=mount_point,
            username=username,
        )
        self.assertEqual(
            first=mock_response,
            second=response,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
def test_configure(self, test_label, mount_point, requests_mocker):
        expected_status_code = 204
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/config'.format(
            mount_point=mount_point,
        )
        requests_mocker.register_uri(
            method='POST',
            url=mock_url,
            status_code=expected_status_code,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.configure(
            user_dn='dc=users,cn=hvac,cn=network',
            group_dn='ou=groups,cn=hvac,cn=network',
            url='ldaps://ldap.python-hvac.org',
            mount_point=mount_point,
        )
        self.assertEqual(
            first=expected_status_code,
            second=response.status_code,
        )
github hvac / hvac / tests / unit_tests / api / auth_methods / test_ldap.py View on Github external
def test_create_or_update_group(self, test_label, mount_point, requests_mocker):
        expected_status_code = 204
        group_name = 'hvac'
        mock_url = 'http://localhost:8200/v1/auth/{mount_point}/groups/{group_name}'.format(
            mount_point=mount_point,
            group_name=group_name,
        )
        requests_mocker.register_uri(
            method='POST',
            url=mock_url,
            status_code=expected_status_code,
        )
        ldap = Ldap(adapter=Request())
        response = ldap.create_or_update_group(
            name=group_name,
            mount_point=mount_point,
        )
        self.assertEqual(
            first=expected_status_code,
            second=response.status_code,
        )
github hvac / hvac / hvac / v1 / __init__.py View on Github external
        new_method=api.auth_methods.Ldap.login,
    )
    def auth_ldap(self, *args, **kwargs):
        return self.auth.ldap.login(*args, **kwargs)