コード例 #1
0
class UserGroupsClientTest(unittest.TestCase):
    def setUp(self):
        self.client = UserGroupsClient(os.environ.get('OKTA_TEST_URL'),
                                       os.environ.get('OKTA_TEST_KEY'))
        self.user_client = UsersClient(os.environ.get('OKTA_TEST_URL'),
                                       os.environ.get('OKTA_TEST_KEY'))

    def test_single_group(self):
        name = 'random_group_' + str(random.random())
        group = UserGroup(name=name, description='something interesting here')
        group = self.client.create_group(group)
        self.assertEqual(group.profile.name, name,
                         "The name for the group wasn't set properly")

    def test_add_user_to_group(self):
        # Create group
        name = 'random_group_' + str(random.random())
        group = UserGroup(name=name, description='something interesting here')
        group = self.client.create_group(group)

        # Create user
        user = User(login='******' + str(random.random()) + '@asdf.com',
                    email='*****@*****.**',
                    firstName='Joe',
                    lastName='Schmoe')
        user = self.user_client.create_user(user, activate=False)

        self.client.add_user_to_group(group, user)
コード例 #2
0
class UserGroupsClientTest(unittest.TestCase):

    def setUp(self):
        self.client = UserGroupsClient(os.environ.get('OKTA_TEST_URL'), os.environ.get('OKTA_TEST_KEY'))
        self.user_client = UsersClient(os.environ.get('OKTA_TEST_URL'), os.environ.get('OKTA_TEST_KEY'))

    def test_single_group(self):
        name = 'random_group_' + str(random.random())
        group = UserGroup(name=name, description='something interesting here')
        group = self.client.create_group(group)
        self.assertEqual(group.profile.name, name, "The name for the group wasn't set properly")

    def test_add_user_to_group(self):
        # Create group
        name = 'random_group_' + str(random.random())
        group = UserGroup(name=name, description='something interesting here')
        group = self.client.create_group(group)

        # Create user
        user = User(login='******' + str(random.random()) + '@asdf.com',
                    email='*****@*****.**',
                    firstName='Joe',
                    lastName='Schmoe')
        user = self.user_client.create_user(user, activate=False)

        self.client.add_user_to_group(group, user)
コード例 #3
0
class UserGroupsClientTest(unittest.TestCase):
    def setUp(self):
        self.client = UserGroupsClient("http://okta.mock.invalid",
                                       "mock-api-key")
        self.user_client = UsersClient("http://okta.mock.invalid",
                                       "mock-api-key")

    @requests_mock.Mocker()
    def test_single_group(self, m):
        name = 'random_group_' + str(random.random())
        m.register_uri("POST",
                       "http://okta.mock.invalid/api/v1/groups/",
                       json={
                           "id": "g0001mock",
                           "profile": {
                               "name": name,
                               "description": "something interesting here"
                           },
                       })
        group = UserGroup(name=name, description="something interesting here")
        group = self.client.create_group(group)
        self.assertEqual(group.profile.name, name,
                         "The name for the group wasn't set properly")

    @requests_mock.Mocker()
    def test_add_user_to_group(self, m):
        # Create group
        m.register_uri("POST",
                       "http://okta.mock.invalid/api/v1/groups/",
                       json={"id": "g0001mock"})
        name = 'random_group_' + str(random.random())
        group = UserGroup(name=name, description='something interesting here')
        group = self.client.create_group(group)

        # Create user
        m.register_uri(
            "POST",
            "http://okta.mock.invalid/api/v1/users/?activate=false",
            json={
                "id": "u0001mock",
                "status": "STAGED",
            },
        )
        user = User(login='******' + str(random.random()) + '@asdf.com',
                    email='*****@*****.**',
                    firstName='Joe',
                    lastName='Schmoe')
        user = self.user_client.create_user(user, activate=False)

        m.register_uri(
            "PUT",
            "http://okta.mock.invalid/api/v1/groups/g0001mock/users/u0001mock",
            json={})
        self.client.add_user_to_group(group, user)