Esempio n. 1
0
 def test_bootstrap_is_not_idempotent_when_password_does_change(self):
     # NOTE(lbragstad): Ensure bootstrap isn't idempotent when run with
     # different arguments or configuration values.
     bootstrap = cli.BootStrap()
     self._do_test_bootstrap(bootstrap)
     v3_token_controller = controllers.Auth()
     v3_password_data = {
         'identity': {
             "methods": ["password"],
             "password": {
                 "user": {
                     "name": bootstrap.username,
                     "password": bootstrap.password,
                     "domain": {
                         "id": CONF.identity.default_domain_id
                     }
                 }
             }
         }
     }
     auth_response = v3_token_controller.authenticate_for_token(
         self.make_request(), v3_password_data)
     token = auth_response.headers['X-Subject-Token']
     os.environ['OS_BOOTSTRAP_PASSWORD'] = uuid.uuid4().hex
     self._do_test_bootstrap(bootstrap)
     # build validation request
     request = self.make_request(is_admin=True)
     request.context_dict['subject_token_id'] = token
     # Since the user account was recovered with a different password, we
     # shouldn't be able to validate this token. Bootstrap should have
     # persisted a revocation event because the user's password was updated.
     # Since this token was obtained using the original password, it should
     # now be invalid.
     self.assertRaises(exception.TokenNotFound,
                       v3_token_controller.validate_token, request)
Esempio n. 2
0
 def test_bootstrap_is_idempotent_when_password_does_not_change(self):
     # NOTE(morganfainberg): Ensure we can run bootstrap with the same
     # configuration multiple times without erroring.
     bootstrap = cli.BootStrap()
     self._do_test_bootstrap(bootstrap)
     v3_token_controller = controllers.Auth()
     v3_password_data = {
         'identity': {
             "methods": ["password"],
             "password": {
                 "user": {
                     "name": bootstrap.username,
                     "password": bootstrap.password,
                     "domain": {
                         "id": CONF.identity.default_domain_id
                     }
                 }
             }
         }
     }
     auth_response = v3_token_controller.authenticate_for_token(
         self.make_request(), v3_password_data)
     token = auth_response.headers['X-Subject-Token']
     self._do_test_bootstrap(bootstrap)
     # build validation request
     request = self.make_request(is_admin=True)
     request.context_dict['subject_token_id'] = token
     # Make sure the token we authenticate for is still valid.
     v3_token_controller.validate_token(request)
Esempio n. 3
0
 def test_assignment_created_with_role_exists(self):
     # test assignment can be created if role already exists.
     bootstrap = cli.BootStrap()
     bootstrap.resource_manager.create_domain(self.default_domain['id'],
                                              self.default_domain)
     role = unit.new_role_ref(name=self.role_name)
     bootstrap.role_manager.create_role(role['id'], role)
     self._do_test_bootstrap(bootstrap)
Esempio n. 4
0
 def test_endpoints_created_with_service_exists(self):
     # test assignment can be created if role already exists.
     bootstrap = cli.BootStrap()
     bootstrap.resource_manager.create_domain(self.default_domain['id'],
                                              self.default_domain)
     service = unit.new_service_ref(name=self.service_name)
     bootstrap.catalog_manager.create_service(service['id'], service)
     self._do_test_bootstrap(bootstrap)
Esempio n. 5
0
 def test_assignment_created_with_region_exists(self):
     # test assignment can be created if role already exists.
     bootstrap = cli.BootStrap()
     bootstrap.resource_manager.create_domain(self.default_domain['id'],
                                              self.default_domain)
     region = unit.new_region_ref(id=self.region_id)
     bootstrap.catalog_manager.create_region(region)
     self._do_test_bootstrap(bootstrap)
Esempio n. 6
0
 def test_assignment_created_with_project_exists(self):
     # test assignment can be created if project already exists.
     bootstrap = cli.BootStrap()
     bootstrap.resource_manager.create_domain(self.default_domain['id'],
                                              self.default_domain)
     project_ref = unit.new_project_ref(self.default_domain['id'],
                                        name=self.project_name)
     bootstrap.resource_manager.create_project(project_ref['id'],
                                               project_ref)
     self._do_test_bootstrap(bootstrap)
Esempio n. 7
0
 def test_assignment_created_with_user_exists(self):
     # test assignment can be created if user already exists.
     bootstrap = cli.BootStrap()
     bootstrap.resource_manager.create_domain(self.default_domain['id'],
                                              self.default_domain)
     user_ref = unit.new_user_ref(self.default_domain['id'],
                                  name=self.username,
                                  password=self.password)
     bootstrap.identity_manager.create_user(user_ref)
     self._do_test_bootstrap(bootstrap)
Esempio n. 8
0
    def test_bootstrap_creates_default_role(self):
        bootstrap = cli.BootStrap()
        try:
            role = bootstrap.role_manager.get_role(CONF.member_role_id)
            self.fail('Member Role is created and should not be.')
        except exception.RoleNotFound:
            pass

        self._do_test_bootstrap(bootstrap)
        role = bootstrap.role_manager.get_role(CONF.member_role_id)
        self.assertEqual(role['name'], CONF.member_role_name)
        self.assertEqual(role['id'], CONF.member_role_id)
Esempio n. 9
0
 def test_bootstrap(self):
     bootstrap = cli.BootStrap()
     bootstrap.do_bootstrap()
     project = bootstrap.resource_manager.get_project_by_name(
         bootstrap.project_name, 'default')
     user = bootstrap.identity_manager.get_user_by_name(
         bootstrap.username, 'default')
     role = bootstrap.role_manager.get_role(bootstrap.role_id)
     role_list = (
         bootstrap.assignment_manager.get_roles_for_user_and_project(
             user['id'], project['id']))
     self.assertIs(len(role_list), 1)
     self.assertEqual(role_list[0], role['id'])
     # NOTE(morganfainberg): Pass an empty context, it isn't used by
     # `authenticate` method.
     bootstrap.identity_manager.authenticate({}, user['id'],
                                             bootstrap.password)
Esempio n. 10
0
    def test_endpoints_created_with_endpoint_exists(self):
        # test assignment can be created if role already exists.
        bootstrap = cli.BootStrap()
        bootstrap.resource_manager.create_domain(self.default_domain['id'],
                                                 self.default_domain)
        service = unit.new_service_ref(name=self.service_name)
        bootstrap.catalog_manager.create_service(service['id'], service)

        region = unit.new_region_ref(id=self.region_id)
        bootstrap.catalog_manager.create_region(region)

        endpoint = unit.new_endpoint_ref(interface='public',
                                         service_id=service['id'],
                                         url=self.public_url,
                                         region_id=self.region_id)
        bootstrap.catalog_manager.create_endpoint(endpoint['id'], endpoint)

        self._do_test_bootstrap(bootstrap)
Esempio n. 11
0
    def test_bootstrap_recovers_user(self):
        bootstrap = cli.BootStrap()
        self._do_test_bootstrap(bootstrap)

        # Completely lock the user out.
        user_id = bootstrap.identity_manager.get_user_by_name(
            bootstrap.username, 'default')['id']
        bootstrap.identity_manager.update_user(user_id, {
            'enabled': False,
            'password': uuid.uuid4().hex
        })

        # The second bootstrap run will recover the account.
        self._do_test_bootstrap(bootstrap)

        # Sanity check that the original password works again.
        bootstrap.identity_manager.authenticate(self.make_request(), user_id,
                                                bootstrap.password)
Esempio n. 12
0
 def test_bootstrap_is_idempotent(self):
     # NOTE(morganfainberg): Ensure we can run bootstrap multiple times
     # without erroring.
     bootstrap = cli.BootStrap()
     self._do_test_bootstrap(bootstrap)
     self._do_test_bootstrap(bootstrap)
Esempio n. 13
0
 def test_bootstrap(self):
     bootstrap = cli.BootStrap()
     self._do_test_bootstrap(bootstrap)