How to use the towerlib.entities.User function in towerlib

To help you get started, we’ve selected a few towerlib 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 schubergphilis / towerlib / tests / integration / test_project.py View on Github external
def test_created_by_attribute(self):
        with self.recorder:
            self.assertIsInstance(self.project.created_by, User)
github schubergphilis / towerlib / tests / integration / test_towerlib.py View on Github external
def test_user_retrieval(self):
        with self.recorder:
            admin_user = self.tower.get_user_by_username('admin')
            self.assertIsInstance(admin_user, User)
            self.assertIsNone(self.tower.get_user_by_username('NoSuchUser'))
            self.assertTrue(admin_user.username == self.tower.get_user_by_id(admin_user.id).username)
github schubergphilis / towerlib / tests / integration / test_towerlib.py View on Github external
def test_user_lifecycle(self):
        with self.recorder:
            user = self.tower.create_user('new_user',
                                          'password',
                                          'first_name',
                                          'last_name',
                                          'new@user.com')
            self.assertIsInstance(user, User)
            duplicate_user = self.tower.create_user('new_user',
                                                    'password2',
                                                    'first_name2',
                                                    'last_name2',
                                                    'new2s@user.com')
            self.assertIsNone(duplicate_user)
            self.assertTrue(self.tower.delete_user('new_user'))
            with self.assertRaises(InvalidUser):
                self.tower.delete_user('new_user')
github schubergphilis / towerlib / towerlib / towerlib.py View on Github external
User: The created User object on success, None otherwise.

        """
        url = '{api}/users/'.format(api=self.api)
        payload = {
            'username': username,
            'first_name': first_name,
            'last_name': last_name,
            'email': email,
            'password': password,
            'is_superuser': is_superuser,
            'is_system_auditor': is_system_auditor}
        response = self.session.post(url, json=payload)
        if not response.ok:
            self._logger.error('Error creating user, response was: "%s"', response.text)
        return User(self, response.json()) if response.ok else None
github schubergphilis / towerlib / towerlib / __init__.py View on Github external
assert InvalidHost
assert InvalidProject
assert InvalidCredentialType
assert InvalidPlaybook
assert InvalidInstanceGroup
assert InvalidJobType
assert InvalidVerbosity
assert InvalidJobTemplate
assert PermissionNotFound
assert InvalidValue
assert InvalidRole

# assert objects
assert Tower
assert Organization
assert User
assert Role
assert Team
assert Project
assert Group
assert Inventory
assert Host
assert Instance
assert InstanceGroup
assert CredentialType
assert Credential
assert InventorySource