@test.create_stubs({api.keystone: ('get_default_domain',
                                       'tenant_list',
                                       'role_list',
                                       'get_default_role')})
    def test_create_validation_for_password_too_short(self):
        user = self.users.get(id="1")
        domain = self._get_default_domain()
        domain_id = domain.id

        api.keystone.get_default_domain(IgnoreArg()) \
            .MultipleTimes().AndReturn(domain)

        if api.keystone.VERSIONS.active >= 3:
            api.keystone.tenant_list(
                IgnoreArg(), domain=domain_id).AndReturn(
                [self.tenants.list(), False])
        else:
            api.keystone.tenant_list(
                IgnoreArg(), user=None).AndReturn(
                [self.tenants.list(), False])

        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.get_default_role(IgnoreArg()) \
                    .AndReturn(self.roles.first())
        if django.VERSION >= (1, 9):
            if api.keystone.VERSIONS.active >= 3:
                api.keystone.tenant_list(
                    IgnoreArg(), domain=domain_id).AndReturn(
                    [self.tenants.list(), False])
            else:
                api.keystone.tenant_list(
                    IgnoreArg(), user=None).AndReturn(
                    [self.tenants.list(), False])

            api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
            api.keystone.get_default_role(IgnoreArg()) \
                .AndReturn(self.roles.first())

        self.mox.ReplayAll()

        # check password min-len verification
        formData = {'method': 'CreateUserForm',
                    'domain_id': domain_id,
                    'name': user.name,
                    'email': user.email,
                    'password': 'four',
                    'project': self.tenant.id,
                    'role_id': self.roles.first().id,
                    'confirm_password': 'four'}

        res = self.client.post(USER_CREATE_URL, formData)

        self.assertFormError(
            res, "form", 'password',
            ['Password must be between 8 and 18 characters.'])
dataset/ETHPy150Open openstack/horizon/openstack_dashboard/dashboards/identity/users/tests.py/UsersViewTests.test_create_validation_for_password_too_short/original