コード例 #1
0
 def _assert_valid_token_authenticates(self):
     user_pass_header = util.get_auth_header(username='******',
                                             password='******')
     client = CloudifyClient(host=self.env.management_ip,
                             headers=user_pass_header)
     token_header = util.get_auth_header(token=client.tokens.get().value)
     self.client = CloudifyClient(self.env.management_ip,
                                  headers=token_header)
     self._assert_authorized()
コード例 #2
0
    def _assert_valid_token_authenticates(self):
        user_pass_header = util.get_auth_header(username="******", password="******")
        client = CloudifyClient(host=self.env.management_ip, headers=user_pass_header)

        token_header = util.get_auth_header(token=client.tokens.get().value)
        client = CloudifyClient(self.env.management_ip, headers=token_header)

        response = client.manager.get_status()
        if not response["status"] == "running":
            raise RuntimeError("Failed to get manager status using token")
コード例 #3
0
    def _assert_valid_token_authenticates(self):
        user_pass_header = util.get_auth_header(username='******',
                                                password='******')
        client = CloudifyClient(host=self.env.management_ip,
                                headers=user_pass_header)

        token_header = util.get_auth_header(token=client.tokens.get().value)
        client = CloudifyClient(self.env.management_ip, headers=token_header)

        response = client.manager.get_status()
        if not response['status'] == 'running':
            raise RuntimeError('Failed to get manager status using token')
コード例 #4
0
    def _assert_valid_token_authenticates(self):
        user_pass_header = util.get_auth_header(username='******',
                                                password='******')
        client = CloudifyClient(host=self.env.management_ip,
                                headers=user_pass_header)

        token_header = util.get_auth_header(token=client.tokens.get().value)
        client = CloudifyClient(self.env.management_ip, headers=token_header)

        response = client.blueprints.list()
        if not response['status'] == 'running':
            raise RuntimeError('Failed to get manager status using token')
コード例 #5
0
 def _assert_unauthorized_user_fails(self):
     client = CloudifyClient(host=self.env.management_ip,
                             headers=util.get_auth_header(
                                 username='******',
                                 password='******'))
     self.assertRaisesRegexp(CloudifyClientError, '401: user unauthorized',
                             client.blueprints.list())
コード例 #6
0
 def _assert_unauthorized_user_fails(self):
     client = CloudifyClient(host=self.env.management_ip,
                             headers=util.get_auth_header(
                                 username='******',
                                 password='******'))
     self.assertRaisesRegexp(UserUnauthorizedError,
                             '401: user unauthorized',
                             client.manager.get_status)
コード例 #7
0
 def _assert_unauthorized_user_fails(self):
     client = CloudifyClient(host=self.env.management_ip,
                             headers=util.get_auth_header(
                                 username='******',
                                 password='******'))
     self.assertRaisesRegexp(UserUnauthorizedError,
                             '401: user unauthorized',
                             client.manager.get_status)
コード例 #8
0
 def _test_verify_missing_cert(self):
     client = CloudifyClient(host=self.env.management_ip,
                             port=constants.SECURED_REST_PORT,
                             protocol=constants.SECURED_PROTOCOL,
                             headers=util.get_auth_header(
                                 username=TEST_CFY_USERNAME,
                                 password=TEST_CFY_PASSWORD),
                             trust_all=False)
     try:
         client.manager.get_status()
         self.fail('certification verification expected to fail')
     except SSLError as e:
         self.assertIn('certificate verify failed', str(e.message))
コード例 #9
0
    def _test_no_verify_cert(self):
        client = CloudifyClient(
            host=self.env.management_ip,
            port=constants.SECURED_REST_PORT,
            protocol=constants.SECURED_PROTOCOL,
            headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                         password=TEST_CFY_PASSWORD),
            trust_all=True)

        response = client.manager.get_status()
        if not response['status'] == 'running':
            raise RuntimeError('Manager at {0} is not running.'
                               .format(self.env.management_ip))
コード例 #10
0
 def _test_verify_missing_cert(self):
     client = CloudifyClient(
         host=self.env.management_ip,
         port=constants.SECURED_REST_PORT,
         protocol=constants.SECURED_PROTOCOL,
         headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                      password=TEST_CFY_PASSWORD),
         trust_all=False)
     try:
         client.manager.get_status()
         self.fail('certification verification expected to fail')
     except SSLError as e:
         self.assertIn('certificate verify failed', str(e.message))
コード例 #11
0
    def _test_no_verify_cert(self):
        client = CloudifyClient(host=self.env.management_ip,
                                port=constants.SECURED_REST_PORT,
                                protocol=constants.SECURED_PROTOCOL,
                                headers=util.get_auth_header(
                                    username=TEST_CFY_USERNAME,
                                    password=TEST_CFY_PASSWORD),
                                trust_all=True)

        response = client.manager.get_status()
        if not response['status'] == 'running':
            raise RuntimeError('Manager at {0} is not running.'.format(
                self.env.management_ip))
コード例 #12
0
 def _test_try_to_connect_to_manager_on_non_secured_port(self):
     try:
         client = CloudifyClient(
             host=self.env.management_ip,
             port=constants.DEFAULT_REST_PORT,
             protocol=constants.DEFAULT_PROTOCOL,
             headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                          password=TEST_CFY_PASSWORD))
         client.manager.get_status()
         self.fail(
             'manager should not be available on port '
             .format(constants.DEFAULT_REST_PORT))
     except ConnectionError as e:
         self.assertIn('Connection refused', str(e.message))
コード例 #13
0
    def _test_try_to_connect_to_manager_on_non_secured_port(self):
        client = CloudifyClient(host=self.env.management_ip,
                                port=constants.DEFAULT_REST_PORT,
                                protocol=constants.DEFAULT_PROTOCOL,
                                headers=util.get_auth_header(
                                    username=TEST_CFY_USERNAME,
                                    password=TEST_CFY_PASSWORD),
                                cert=self.cert_path,
                                trust_all=False)

        response = client.manager.get_status()
        if not response['status'] == 'running':
            raise RuntimeError(
                'Failed to get server status from {0}://{1}:{2}'.format(
                    constants.DEFAULT_PROTOCOL, self.env.management_ip,
                    constants.DEFAULT_REST_PORT))
コード例 #14
0
    def set_rest_client(self):
        self.client = CloudifyClient(
            host=self.env.management_ip,
            port=constants.SECURED_REST_PORT,
            protocol=constants.SECURED_PROTOCOL,
            headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                         password=TEST_CFY_PASSWORD),
            trust_all=True)

    # def _running_env_setup(self):
    #     self.env.management_ip = self.cfy.get_management_ip()
    #     self.set_rest_client()

        def clean_mgmt_ip():
            self.env.management_ip = None
        self.addCleanup(clean_mgmt_ip)
コード例 #15
0
    def _test_try_to_connect_to_manager_on_non_secured_port(self):
        client = CloudifyClient(
            host=self.env.management_ip,
            port=constants.DEFAULT_REST_PORT,
            protocol=constants.DEFAULT_PROTOCOL,
            headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                         password=TEST_CFY_PASSWORD),
            cert=self.cert_path,
            trust_all=False)

        response = client.manager.get_status()
        if not response['status'] == 'running':
            raise RuntimeError('Failed to get server status from {0}://{1}:{2}'
                               .format(constants.DEFAULT_PROTOCOL,
                                       self.env.management_ip,
                                       constants.DEFAULT_REST_PORT))
コード例 #16
0
    def set_rest_client(self):
        self.client = CloudifyClient(
            host=self.env.management_ip,
            port=constants.SECURED_REST_PORT,
            protocol=constants.SECURED_PROTOCOL,
            headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                         password=TEST_CFY_PASSWORD),
            trust_all=True)

    # def _running_env_setup(self):
    #     self.env.management_ip = self.cfy.get_management_ip()
    #     self.set_rest_client()

        def clean_mgmt_ip():
            self.env.management_ip = None
        self.addCleanup(clean_mgmt_ip)
コード例 #17
0
 def _test_verify_wrong_cert(self):
     cert_path = os.path.join(self.workdir, 'wrong.cert')
     key_path = os.path.join(self.workdir, 'wrong.key')
     self.create_self_signed_certificate(cert_path, key_path, 'test')
     client = CloudifyClient(host=self.env.management_ip,
                             port=constants.SECURED_REST_PORT,
                             protocol=constants.SECURED_PROTOCOL,
                             headers=util.get_auth_header(
                                 username=TEST_CFY_USERNAME,
                                 password=TEST_CFY_PASSWORD),
                             cert=util.get_resource_path(cert_path),
                             trust_all=False)
     try:
         client.manager.get_status()
         self.fail('certification verification expected to fail')
     except SSLError as e:
         self.assertIn('certificate verify failed', str(e.message))
コード例 #18
0
 def _test_verify_wrong_cert(self):
     cert_path = os.path.join(self.workdir, 'wrong.cert')
     key_path = os.path.join(self.workdir, 'wrong.key')
     self.create_self_signed_certificate(cert_path, key_path, 'test')
     client = CloudifyClient(
         host=self.env.management_ip,
         port=constants.SECURED_REST_PORT,
         protocol=constants.SECURED_PROTOCOL,
         headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                      password=TEST_CFY_PASSWORD),
         cert=util.get_resource_path(cert_path),
         trust_all=False)
     try:
         client.manager.get_status()
         self.fail('certification verification expected to fail')
     except SSLError as e:
         self.assertIn('certificate verify failed', str(e.message))
コード例 #19
0
 def _create_client(self, username=None, password=None, token=None):
     user_pass_header = util.get_auth_header(username=username,
                                             password=password,
                                             token=token)
     return util.create_rest_client(self.env.management_ip,
                                    headers=user_pass_header)
コード例 #20
0
 def _assert_invalid_user_fails(self):
     client = CloudifyClient(host=self.env.management_ip,
                             headers=util.get_auth_header(username='******',
                                                          password='******'))
     self.assertRaisesRegexp(CloudifyClientError, '401: user unauthorized',
                             client.manager.get_status)
コード例 #21
0
 def set_rest_client(self):
     self.client = CloudifyClient(host=self.env.management_ip,
                                  headers=util.get_auth_header(
                                      username='******',
                                      password='******'))
コード例 #22
0
 def _assert_empty_token_fails(self):
     token_header = util.get_auth_header(token='')
     self.client = CloudifyClient(host=self.env.management_ip,
                                  headers=token_header)
     self._assert_unauthorized()
コード例 #23
0
 def _assert_invalid_token_fails(self):
     token_header = util.get_auth_header(token='wrong_token')
     self.client = CloudifyClient(self.env.management_ip,
                                  headers=token_header)
     self._assert_unauthorized()
コード例 #24
0
 def _get_execution_ids(self):
     auth_header = util.get_auth_header(ADMIN_USERNAME, ADMIN_PASSWORD)
     alice_client = CloudifyClient(host=self.env.management_ip,
                                   headers=auth_header)
     return [execution.id for execution in alice_client.executions.list()]
コード例 #25
0
 def set_rest_client(self):
     self.client = CloudifyClient(
         host=self.env.management_ip,
         headers=util.get_auth_header(username='******',
                                      password='******'))
コード例 #26
0
 def _assert_valid_credentials_authenticate(self):
     user_pass_header = util.get_auth_header(username='******',
                                             password='******')
     self.client = CloudifyClient(host=self.env.management_ip,
                                  headers=user_pass_header)
     self._assert_authorized()
コード例 #27
0
 def _assert_authorized_user_succeeds(self):
     user_pass_header = util.get_auth_header(username='******',
                                             password='******')
     CloudifyClient(host=self.env.management_ip, headers=user_pass_header)
コード例 #28
0
 def _assert_invalid_token_fails(self):
     token_header = util.get_auth_header(token='wrong_token')
     client = CloudifyClient(self.env.management_ip, headers=token_header)
     self.assertRaisesRegexp(CloudifyClientError, '401: user unauthorized',
                             client.blueprints.list())
コード例 #29
0
 def set_rest_client(self):
     self.client = util.create_rest_client(
         self.env.management_ip,
         headers=util.get_auth_header(username=self.TEST_CFY_USERNAME,
                                      password=self.TEST_CFY_PASSWORD))
     self.env.rest_client = self.client
コード例 #30
0
 def _assert_unauthorized_user_fails(self):
     client = CloudifyClient(
         host=self.env.management_ip, headers=util.get_auth_header(username="******", password="******")
     )
     self.assertRaisesRegexp(CloudifyClientError, "401: user unauthorized", client.manager.get_status)
コード例 #31
0
 def _create_client(self, username=None, password=None, token=None):
     user_pass_header = util.get_auth_header(username=username,
                                             password=password,
                                             token=token)
     return CloudifyClient(host=self.env.management_ip,
                           headers=user_pass_header)
コード例 #32
0
 def _assert_invalid_token_fails(self):
     token_header = util.get_auth_header(token='wrong_token')
     client = CloudifyClient(self.env.management_ip, headers=token_header)
     self.assertRaisesRegexp(CloudifyClientError, '401: user unauthorized',
                             client.manager.get_status)
コード例 #33
0
 def _assert_empty_credentials_fails(self):
     user_pass_header = util.get_auth_header(username='',
                                             password='')
     self.client = CloudifyClient(host=self.env.management_ip,
                                  headers=user_pass_header)
     self._assert_unauthorized()
コード例 #34
0
 def set_rest_client(self):
     self.client = CloudifyClient(
         host=self.env.management_ip,
         headers=util.get_auth_header(username=TEST_CFY_USERNAME,
                                      password=TEST_CFY_PASSWORD))
コード例 #35
0
 def _assert_invalid_token_fails(self):
     token_header = util.get_auth_header(token="wrong_token")
     client = CloudifyClient(self.env.management_ip, headers=token_header)
     self.assertRaisesRegexp(CloudifyClientError, "401: user unauthorized", client.manager.get_status)
コード例 #36
0
 def _assert_invalid_user_fails(self):
     client = CloudifyClient(host=self.env.management_ip,
                             headers=util.get_auth_header(username='******',
                                                          password='******'))
     self.assertRaisesRegexp(CloudifyClientError, '401: user unauthorized',
                             client.manager.get_status)
コード例 #37
0
 def set_rest_client(self):
     self.client = CloudifyClient(host=self.env.management_ip,
                                  headers=util.get_auth_header(
                                      username=TEST_CFY_USERNAME,
                                      password=TEST_CFY_PASSWORD))