def get_idm_version_info():
    idm_cfg = IDMConfig()

    logger.info("Get software version of the OpenIDM instance")
    headers = idm_cfg.get_admin_headers({'Content-Type': 'application/json'})
    response = get(verify=idm_cfg.ssl_verify,
                   url=idm_cfg.idm_url + '/info/version',
                   headers=headers)
    rest.check_http_status(http_result=response, expected_status=200)
    version_info = "{} (build: {}, revision: {})".format(
        response.json()['productVersion'],
        response.json()['productBuildDate'],
        response.json()['productRevision'])
    return version_info
Exemplo n.º 2
0
class TestIntegration(object):
    amcfg = AMConfig()
    idmcfg = IDMConfig()

    def test_1_idm_create_user_am_login_user(self):
        """
        Creates a user in IDM and tries to login with user with AM
        """
        username = '******'
        password = '******'

        user_payload = json.dumps({
            'userName': username,
            'telephoneNumber': '6669876987',
            'givenName': 'CreatedInIdm',
            'description': 'Just another user',
            'sn': 'idmcreateduser',
            'mail': '*****@*****.**',
            'password': password,
            'accountStatus': 'active'
        })

        logger.test_step('Creating user in IDM')
        self.idmcfg.create_user(user_payload)
        logger.test_step('Trying to login created user to AM')
        self.amcfg.login_user(username, password)
        logger.test_step('Deleting user with AM')
        self.amcfg.delete_user(username)
Exemplo n.º 3
0
    def version(self):
        """
        Return the product version information.
        :return: Dictionary
        """
        idm_cfg = IDMConfig()

        logger.info("Get software version of the OpenIDM instance")
        headers = idm_cfg.get_admin_headers(
            {'Content-Type': 'application/json'})
        response = get(verify=idm_cfg.ssl_verify,
                       url=idm_cfg.idm_url + '/info/version',
                       headers=headers)
        rest.check_http_status(http_result=response, expected_status=200)

        return {
            'TITLE': self.product_type,
            'DESCRIPTION': self.name,
            'VERSION': response.json()['productVersion'],
            'REVISION': response.json()['productRevision'],
            'DATE': response.json()['productBuildDate']
        }
Exemplo n.º 4
0
class IDMSmoke(unittest.TestCase):
    idmcfg = IDMConfig()
    testuser = '******'

    def test_0_ping(self):
        """Pings OpenIDM to see if server is alive using admin headers"""
        resp = get(verify=self.idmcfg.ssl_verify,
                   auth=('openidm-admin', 'openidm-admin'),
                   url=self.idmcfg.rest_ping_url)
        self.assertEqual(resp.status_code, 200)

    def test_1_create_managed_user(self):
        """Test to create managed user as admin"""
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-none-match': '*'
        })

        payload = """{"userName": "******",
                   "telephoneNumber": "6669876987",
                   "givenName": "devopsguy",
                   "description": "Just another user",
                   "sn": "sutter",
                   "mail": "*****@*****.**",
                   "password": "******",
                   "accountStatus": "active" } """

        resp = put(verify=self.idmcfg.ssl_verify,
                   url=self.idmcfg.rest_managed_user_url + self.testuser,
                   headers=headers,
                   data=payload)
        self.assertEqual(201, resp.status_code, 'Create test user')

    def test_2_update_managed_user(self):
        """Test to update managed user as admin"""
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-match': '*'
        })
        payload = """{"userName": "******",
                   "telephoneNumber": "6669876987",
                   "givenName": "devopsguy",
                   "description": "Just another user",
                   "sn": "sutter",
                   "mail": "*****@*****.**",
                   "password": "******",
                   "accountStatus": "active"} """

        resp = put(verify=self.idmcfg.ssl_verify,
                   url=self.idmcfg.rest_managed_user_url + self.testuser,
                   headers=headers,
                   data=payload)
        self.assertEqual(200, resp.status_code,
                         'Update test user - ' + str(resp.text))

    def test_3_run_recon_to_ldap(self):
        """Test to run reconciliation to ldap"""
        headers = self.idmcfg.get_admin_headers(
            {'Content-Type': 'application/json'})

        params = {
            '_action': 'recon',
            'mapping': 'managedUser_systemLdapAccounts',
            'waitForCompletion': 'True'
        }

        resp = post(verify=self.idmcfg.ssl_verify,
                    url=self.idmcfg.idm_url + '/recon',
                    params=params,
                    headers=headers)
        self.assertEqual(200, resp.status_code, "Reconciliation")

    def test_4_login_managed_user(self):
        """Test login as managed user"""
        headers = {
            'X-OpenIDM-Username': '******',
            'X-OpenIDM-Password': '******',
            'Content-Type': 'application/json',
        }
        resp = get(verify=self.idmcfg.ssl_verify,
                   url=self.idmcfg.rest_ping_url,
                   headers=headers)
        self.assertEqual(200, resp.status_code,
                         "Login managed user and access ping endpoint")

    def test_5_delete_managed_user(self):
        """Test to delete managed user as admin"""
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-match': '*',
        })
        resp = delete(verify=self.idmcfg.ssl_verify,
                      url=self.idmcfg.rest_managed_user_url + self.testuser,
                      headers=headers)
        self.assertEqual(200, resp.status_code, "Delete test user")

    def test_6_user_self_registration(self):
        """Test to use self service registration as user"""
        user_data = {
            "input": {
                "user": {
                    "userName": "******",
                    "givenName": "rick",
                    "sn": "sutter",
                    "mail": "*****@*****.**",
                    "password": "******",
                    "preferences": {
                        "updates": False,
                        "marketing": False
                    }
                },
                "kba": [{
                    "answer": "black",
                    "questionId": "1"
                }]
            }
        }

        headers = {
            'Content-Type': 'application/json',
            'X-OpenIDM-Username': '******',
            'X-OpenIDM-Password': '******',
            'Cache-Control': 'no-cache'
        }
        params = {'_action': 'submitRequirements'}
        resp = post(verify=self.idmcfg.ssl_verify,
                    url=self.idmcfg.rest_selfreg_url,
                    params=params,
                    headers=headers,
                    json=user_data)
        token = resp.json()["token"]
        user_data["token"] = token
        resp = post(verify=self.idmcfg.ssl_verify,
                    url=self.idmcfg.rest_selfreg_url,
                    params=params,
                    headers=headers,
                    json=user_data)

        self.assertEqual(200, resp.status_code)
        self.assertTrue(resp.json()['status']['success'],
                        "Expecting success in returned json")

    def test_7_user_reset_pw(self):
        """Test to use self service password reset as user"""
        s = session()
        headers_init = {
            'Content-Type': 'application/json',
            'X-OpenIDM-Username': '******',
            'X-OpenIDM-Password': '******',
            'Cache-Control': 'no-cache',
            'X-OpenIDM-NoSession': "true",
            "Accept-API-Version": "protocol=1.0,resource=1.0"
        }

        headers = {
            'Content-Type': 'application/json',
            'X-OpenIDM-Username': '******',
            'X-OpenIDM-Password': '******',
            'Cache-Control': 'no-cache'
        }

        params = {'_action': 'submitRequirements'}

        payload1 = {"input": {'queryFilter': 'userName eq \"rsutter\"'}}

        stage1 = s.post(verify=self.idmcfg.ssl_verify,
                        url=self.idmcfg.rest_selfpwreset_url,
                        headers=headers_init,
                        params=params,
                        json=payload1)
        self.assertEqual(200, stage1.status_code,
                         "Try to find user with query for pw reset")

        payload2 = {
            "token": stage1.json()["token"],
            "input": {
                'queryFilter': 'userName eq \"rsutter\"'
            }
        }
        stage2 = s.post(verify=self.idmcfg.ssl_verify,
                        url=self.idmcfg.rest_selfpwreset_url,
                        headers=headers_init,
                        params=params,
                        json=payload2)
        self.assertEqual(200, stage2.status_code, "Stage 2 - Query user")

        payload3 = {
            "token": stage2.json()["token"],
            "input": {
                "answer1": "black"
            }
        }

        stage3 = s.post(verify=self.idmcfg.ssl_verify,
                        url=self.idmcfg.rest_selfpwreset_url,
                        headers=headers,
                        params=params,
                        json=payload3)
        self.assertEqual(200, stage3.status_code, "Stage 3 - Answer question")

        payload4 = {
            "token": stage3.json()["token"],
            "input": {
                "password": "******"
            }
        }

        stage4 = s.post(verify=self.idmcfg.ssl_verify,
                        url=self.idmcfg.rest_selfpwreset_url,
                        headers=headers,
                        params=params,
                        json=payload4)
        self.assertEqual(200, stage4.status_code, "Stage 4 - Password reset")
        s.close()
Exemplo n.º 5
0
class IDMSmoke(unittest.TestCase):
    idmcfg = IDMConfig()
    testuser = '******'

    def test_0_ping(self):
        resp = get(auth=('openidm-admin', 'openidm-admin'), url=self.idmcfg.rest_ping_url)
        self.assertEqual(resp.status_code, 200)

    def test_1_create_managed_user(self):
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-none-match': '*'
        })

        payload = """{"userName": "******",
                   "telephoneNumber": "6669876987",
                   "givenName": "devopsguy",
                   "description": "Just another user",
                   "sn": "sutter",
                   "mail": "*****@*****.**",
                   "password": "******",
                   "accountStatus": "active" } """

        resp = put(url=self.idmcfg.rest_managed_user_url + self.testuser, headers=headers, data=payload)
        self.assertEqual(201, resp.status_code, 'Create test user')

    def test_2_update_managed_user(self):
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-match': '*'})
        payload = """{"userName": "******",
                   "telephoneNumber": "6669876987",
                   "givenName": "devopsguy",
                   "description": "Just another user",
                   "sn": "sutter",
                   "mail": "*****@*****.**",
                   "password": "******",
                   "accountStatus": "active"} """

        resp = put(url=self.idmcfg.rest_managed_user_url + self.testuser, headers=headers, data=payload)
        self.assertEqual(200, resp.status_code, 'Update test user')

    def test_3_run_recon_to_ldap(self):
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json'
        })

        params = {
            '_action': 'recon',
            'mapping': 'managedUser_systemLdapAccounts',
            'waitForCompletion': 'True'
        }

        resp = post(url=self.idmcfg.idm_url + '/recon', params=params, headers=headers)
        self.assertEqual(200, resp.status_code, "Reconciliation")

    def test_4_login_managed_user(self):
        headers = {'X-OpenIDM-Username': '******',
                   'X-OpenIDM-Password': '******',
                   'Content-Type': 'application/json',
                   }
        resp = get(url=self.idmcfg.rest_ping_url, headers=headers)
        self.assertEqual(200, resp.status_code, "Login managed user and access ping endpoint")

    def test_5_delete_managed_user(self):
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-match': '*',
        })
        resp = delete(url=self.idmcfg.rest_managed_user_url + self.testuser, headers=headers)
        self.assertEqual(200, resp.status_code, "Delete test user")
Exemplo n.º 6
0
class TestIDM(object):
    idmcfg = IDMConfig()
    testuser = '******'

    def test_0_ping(self):
        """Simple ping test to IDM"""

        logger.test_step('Ping OpenIDM')
        response = get(verify=self.idmcfg.ssl_verify,
                       url=self.idmcfg.rest_ping_url,
                       headers=self.idmcfg.get_admin_headers(None))
        rest.check_http_status(http_result=response, expected_status=200)

    def test_1_create_managed_user(self):
        """Test to create managed user as admin"""

        payload = """{"userName": "******",
                   "telephoneNumber": "6669876987",
                   "givenName": "devopsguy",
                   "description": "Just another user",
                   "sn": "sutter",
                   "mail": "*****@*****.**",
                   "password": "******",
                   "accountStatus": "active" } """

        logger.test_step('Create test user')
        self.idmcfg.create_user(payload)

    def test_2_update_managed_user(self):
        """Test to update managed user as admin"""
        headers = self.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'If-Match': '*'
        })

        user_id = self.idmcfg.get_userid_by_name(self.testuser)
        payload = """[{"operation":"replace", "field":"/telephoneNumber", "value":"15031234567"}]"""

        logger.test_step('Update test user')
        response = patch(verify=self.idmcfg.ssl_verify,
                         url=f'{self.idmcfg.rest_managed_user_url}/{user_id}',
                         headers=headers,
                         data=payload)
        rest.check_http_status(response, expected_status=200)

    def test_3_delete_managed_user(self):
        """Test to delete managed user as admin"""
        user_id = self.idmcfg.get_userid_by_name(self.testuser)
        self.idmcfg.delete_user(user_id)

    @classmethod
    def teardown_class(cls):
        """"""

        headers1 = cls.idmcfg.get_admin_headers(
            {'Content-Type': 'application/json'})

        logger.test_step('Get user id')
        response = get(verify=cls.idmcfg.ssl_verify,
                       url=cls.idmcfg.rest_managed_user_url +
                       '?_queryFilter=true',
                       headers=headers1).json()
        # rest.check_http_status(http_result=response, expected_status=200)
        if response['resultCount'] == 0:
            return
        _id = response["result"][0]["_id"]

        headers2 = cls.idmcfg.get_admin_headers({
            'Content-Type': 'application/json',
            'if-match': '*',
        })

        logger.test_step('Delete user')
        response = delete(verify=cls.idmcfg.ssl_verify,
                          url=cls.idmcfg.rest_managed_user_url + '/' + _id,
                          headers=headers2)
        rest.check_http_status(http_result=response, expected_status=200)