示例#1
0
    def test_authenticate_failure(self):
        ident = self.TEST_REQUEST_BODY['auth']['identity']
        ident['password']['user']['password'] = '******'
        error = {"unauthorized": {"message": "Unauthorized", "code": "401"}}

        self.stub_auth(status_code=401, json=error)

        with testcase.ExpectedException(exceptions.Unauthorized):
            with self.deprecations.expect_deprecations_here():
                client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
                              username=self.TEST_USER,
                              password="******",
                              project_id=self.TEST_TENANT_ID,
                              auth_url=self.TEST_URL)

        self.assertRequestBodyIs(json=self.TEST_REQUEST_BODY)
示例#2
0
    def test_authenticate_failure(self):
        _auth = 'auth'
        _cred = 'passwordCredentials'
        _pass = '******'
        self.TEST_REQUEST_BODY[_auth][_cred][_pass] = 'bad_key'
        error = {"unauthorized": {"message": "Unauthorized", "code": "401"}}

        self.stub_auth(status_code=401, json=error)

        with testcase.ExpectedException(exceptions.Unauthorized):
            with self.deprecations.expect_deprecations_here():
                client.Client(username=self.TEST_USER,
                              password="******",
                              project_id=self.TEST_TENANT_ID,
                              auth_url=self.TEST_URL)

        self.assertRequestBodyIs(json=self.TEST_REQUEST_BODY)