Beispiel #1
0
    def test_modal_create_user_with_passwords_not_matching(self):
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.user_list(IgnoreArg()).AndReturn(self.users.list())
        api.keystone.get_default_role(IgnoreArg()) \
                    .AndReturn(self.roles.first())
        self.mox.ReplayAll()

        self.selenium.get("%s%s" % (self.live_server_url, USERS_INDEX_URL))

        # Open the modal menu
        self.selenium.find_element_by_id("users__action_create") \
                     .send_keys("\n")
        wait = self.ui.WebDriverWait(self.selenium, 10)
        wait.until(lambda x: self.selenium.find_element_by_id("id_name"))

        body = self.selenium.find_element_by_tag_name("body")
        self.assertFalse("Passwords do not match" in body.text,
                         "Error message should not be visible at loading time")
        self.selenium.find_element_by_id("id_name").send_keys("Test User")
        self.selenium.find_element_by_id("id_password").send_keys("test")
        self.selenium.find_element_by_id("id_confirm_password").send_keys("te")
        self.selenium.find_element_by_id("id_email").send_keys("*****@*****.**")
        body = self.selenium.find_element_by_tag_name("body")
        self.assertTrue("Passwords do not match" in body.text,
                        "Error message not found in body")
Beispiel #2
0
    def test_update(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), "1", admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.user_update(
            IsA(http.HttpRequest), user.id, email=u"*****@*****.**", name=u"test_user"
        ).AndReturn(None)
        api.user_update_tenant(IsA(http.HttpRequest), user.id, self.tenant.id).AndReturn(None)
        api.keystone.roles_for_user(IsA(http.HttpRequest), user.id, self.tenant.id).AndReturn(None)
        api.user_update_password(IsA(http.HttpRequest), user.id, IgnoreArg()).AndReturn(None)

        self.mox.ReplayAll()

        formData = {
            "method": "UpdateUserForm",
            "id": user.id,
            "name": user.name,
            "email": user.email,
            "password": "******",
            "tenant_id": self.tenant.id,
            "confirm_password": "******",
        }

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

        self.assertNoFormErrors(res)
        self.assertMessageCount(warning=1)
Beispiel #3
0
    def test_create(self):
        user = self.users.get(id="1")
        role = self.roles.first()

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.user_create(IgnoreArg(),
                        user.name,
                        user.email,
                        user.password,
                        self.tenant.id,
                        True).AndReturn(user)
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.get_default_role(IgnoreArg()).AndReturn(role)
        api.add_tenant_user_role(IgnoreArg(), self.tenant.id, user.id, role.id)

        self.mox.ReplayAll()

        formData = {'method': 'CreateUserForm',
                    'name': user.name,
                    'email': user.email,
                    'password': user.password,
                    'tenant_id': self.tenant.id,
                    'role_id': self.roles.first().id,
                    'confirm_password': user.password}
        res = self.client.post(USER_CREATE_URL, formData)

        self.assertNoFormErrors(res)
        self.assertMessageCount(success=1)
Beispiel #4
0
    def test_create_validation_for_password_too_long(self):
        user = self.users.get(id="1")

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        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',
            'name': user.name,
            'email': user.email,
            'password': '******',
            'tenant_id': self.tenant.id,
            'role_id': self.roles.first().id,
            'confirm_password': '******'
        }

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

        self.assertFormError(res, "form", 'password',
                             ['Password must be between 8 and 18 characters.'])
Beispiel #5
0
    def test_update_with_keystone_can_edit_user_false(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), '1', admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone_can_edit_user().AndReturn(False)
        api.keystone_can_edit_user().AndReturn(False)
        api.user_update_tenant(IsA(http.HttpRequest), user.id,
                               self.tenant.id).AndReturn(None)
        api.keystone.roles_for_user(IsA(http.HttpRequest), user.id,
                                    self.tenant.id).AndReturn(None)

        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateUserForm',
            'id': user.id,
            'name': user.name,
            'tenant_id': self.tenant.id,
        }

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

        self.assertNoFormErrors(res)
        self.assertMessageCount(warning=1)
Beispiel #6
0
    def test_update(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), '1', admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.user_update(IsA(http.HttpRequest),
                                 user.id,
                                 email=u'*****@*****.**',
                                 name=u'test_user').AndReturn(None)
        api.user_update_tenant(IsA(http.HttpRequest), user.id,
                               self.tenant.id).AndReturn(None)
        api.keystone.roles_for_user(IsA(http.HttpRequest), user.id,
                                    self.tenant.id).AndReturn(None)
        api.user_update_password(IsA(http.HttpRequest), user.id,
                                 IgnoreArg()).AndReturn(None)

        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateUserForm',
            'id': user.id,
            'name': user.name,
            'email': user.email,
            'password': '******',
            'tenant_id': self.tenant.id,
            'confirm_password': '******'
        }

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

        self.assertNoFormErrors(res)
        self.assertMessageCount(warning=1)
Beispiel #7
0
    def test_modal_create_user_with_passwords_not_matching(self):
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.user_list(IgnoreArg()).AndReturn(self.users.list())
        api.keystone.get_default_role(IgnoreArg()) \
                    .AndReturn(self.roles.first())
        self.mox.ReplayAll()

        self.selenium.get("%s%s" % (self.live_server_url, USERS_INDEX_URL))

        # Open the modal menu
        self.selenium.find_element_by_id("users__action_create") \
                     .send_keys("\n")
        wait = self.ui.WebDriverWait(self.selenium, 10)
        wait.until(lambda x: self.selenium.find_element_by_id("id_name"))

        body = self.selenium.find_element_by_tag_name("body")
        self.assertFalse(
            "Passwords do not match" in body.text,
            "Error message should not be visible at loading time")
        self.selenium.find_element_by_id("id_name").send_keys("Test User")
        self.selenium.find_element_by_id("id_password").send_keys("test")
        self.selenium.find_element_by_id("id_confirm_password").send_keys("te")
        self.selenium.find_element_by_id("id_email").send_keys("*****@*****.**")
        body = self.selenium.find_element_by_tag_name("body")
        self.assertTrue("Passwords do not match" in body.text,
                        "Error message not found in body")
Beispiel #8
0
    def test_create(self):
        user = self.users.get(id="1")
        role = self.roles.first()

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.user_create(IgnoreArg(), user.name, user.email, user.password,
                        self.tenant.id, True).AndReturn(user)
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.get_default_role(IgnoreArg()).AndReturn(role)
        api.add_tenant_user_role(IgnoreArg(), self.tenant.id, user.id, role.id)

        self.mox.ReplayAll()

        formData = {
            'method': 'CreateUserForm',
            'name': user.name,
            'email': user.email,
            'password': user.password,
            'tenant_id': self.tenant.id,
            'role_id': self.roles.first().id,
            'confirm_password': user.password
        }
        res = self.client.post(USER_CREATE_URL, formData)

        self.assertNoFormErrors(res)
        self.assertMessageCount(success=1)
Beispiel #9
0
    def test_update(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), '1',
                     admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(),
                        admin=True).AndReturn(self.tenants.list())
        api.keystone.user_update(IsA(http.HttpRequest),
                                 user.id,
                                 email=u'*****@*****.**',
                                 name=u'test_user').AndReturn(None)
        api.user_update_tenant(IsA(http.HttpRequest),
                               user.id,
                               self.tenant.id).AndReturn(None)
        api.keystone.roles_for_user(IsA(http.HttpRequest),
                                    user.id,
                                    self.tenant.id).AndReturn(None)
        api.user_update_password(IsA(http.HttpRequest),
                                 user.id,
                                 IgnoreArg()).AndReturn(None)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateUserForm',
                    'id': user.id,
                    'name': user.name,
                    'email': user.email,
                    'password': '******',
                    'tenant_id': self.tenant.id,
                    'confirm_password': '******'}

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

        self.assertNoFormErrors(res)
        self.assertMessageCount(warning=1)
Beispiel #10
0
    def test_update_with_keystone_can_edit_user_false(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest),
                     '1',
                     admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone_can_edit_user().AndReturn(False)
        api.keystone_can_edit_user().AndReturn(False)
        api.user_update_tenant(IsA(http.HttpRequest),
                               user.id,
                               self.tenant.id).AndReturn(None)
        api.keystone.roles_for_user(IsA(http.HttpRequest),
                                    user.id,
                                    self.tenant.id).AndReturn(None)

        self.mox.ReplayAll()

        formData = {'method': 'UpdateUserForm',
                    'id': user.id,
                    'name': user.name,
                    'tenant_id': self.tenant.id, }

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

        self.assertNoFormErrors(res)
        self.assertMessageCount(warning=1)
Beispiel #11
0
    def test_update_user_with_passwords_not_matching(self):
        api.user_get(IsA(http.HttpRequest), "1", admin=True).AndReturn(self.user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        self.mox.ReplayAll()

        self.selenium.get("%s%s" % (self.live_server_url, USER_UPDATE_URL))

        body = self.selenium.find_element_by_tag_name("body")
        self.assertFalse("Passwords do not match" in body.text, "Error message should not be visible at loading time")
        self.selenium.find_element_by_id("id_password").send_keys("test")
        self.selenium.find_element_by_id("id_confirm_password").send_keys("te")
        self.selenium.find_element_by_id("id_email").clear()
        body = self.selenium.find_element_by_tag_name("body")
        self.assertTrue("Passwords do not match" in body.text, "Error message not found in body")
Beispiel #12
0
 def __init__(self, request, *args, **kwargs):
     super(DownloadOpenRCForm, self).__init__(request, *args, **kwargs)
     # Populate tenant choices
     tenant_choices = []
     for tenant in api.tenant_list(request):
         if tenant.enabled:
             tenant_choices.append((tenant.id, tenant.name))
     self.fields['tenant'].choices = tenant_choices
Beispiel #13
0
 def __init__(self, request, *args, **kwargs):
     super(DownloadOpenRCForm, self).__init__(request, *args, **kwargs)
     # Populate tenant choices
     tenant_choices = []
     for tenant in api.tenant_list(request):
         if tenant.enabled:
             tenant_choices.append((tenant.id, tenant.name))
     self.fields['tenant'].choices = tenant_choices
Beispiel #14
0
    def test_update_user_with_passwords_not_matching(self):
        api.user_get(IsA(http.HttpRequest), '1',
                     admin=True).AndReturn(self.user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        self.mox.ReplayAll()

        self.selenium.get("%s%s" % (self.live_server_url, USER_UPDATE_URL))

        body = self.selenium.find_element_by_tag_name("body")
        self.assertFalse(
            "Passwords do not match" in body.text,
            "Error message should not be visible at loading time")
        self.selenium.find_element_by_id("id_password").send_keys("test")
        self.selenium.find_element_by_id("id_confirm_password").send_keys("te")
        self.selenium.find_element_by_id("id_email").clear()
        body = self.selenium.find_element_by_tag_name("body")
        self.assertTrue("Passwords do not match" in body.text,
                        "Error message not found in body")
Beispiel #15
0
    def __init__(self, request, *args, **kwargs):
        super(BaseUserForm, self).__init__(request, *args, **kwargs)
        # Populate tenant choices
        tenant_choices = [('', _("Select a project"))]

        for tenant in api.tenant_list(request, admin=True):
            if tenant.enabled:
                tenant_choices.append((tenant.id, tenant.name))
        self.fields['tenant_id'].choices = tenant_choices
Beispiel #16
0
    def __init__(self, request, *args, **kwargs):
        super(BaseUserForm, self).__init__(request, *args, **kwargs)
        # Populate tenant choices
        tenant_choices = [('', _("Select a project"))]

        for tenant in api.tenant_list(request, admin=True):
            if tenant.enabled:
                tenant_choices.append((tenant.id, tenant.name))
        self.fields['tenant_id'].choices = tenant_choices
def index(request):
    for f in (DeleteTenantForm,):
        _, handled = f.maybe_handle(request)
        if handled:
            return handled

    tenants = []
    try:
        tenants = api.tenant_list(request)
    except api_exceptions.ApiException, e:
        LOG.error('ApiException while getting tenant list', exc_info=True)
        messages.error(request, 'Unable to get tenant info: %s' % e.message)
Beispiel #18
0
    def test_update_validation_for_password_too_long(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), "1", admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())

        self.mox.ReplayAll()

        formData = {
            "method": "UpdateUserForm",
            "id": user.id,
            "name": user.name,
            "email": user.email,
            "password": "******",
            "tenant_id": self.tenant.id,
            "confirm_password": "******",
        }

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

        self.assertFormError(res, "form", "password", ["Password must be between 8 and 18 characters."])
Beispiel #19
0
    def test_create_with_password_mismatch(self):
        user = self.users.get(id="1")

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.get_default_role(IgnoreArg()) \
                    .AndReturn(self.roles.first())

        self.mox.ReplayAll()

        formData = {'method': 'CreateUserForm',
                    'name': user.name,
                    'email': user.email,
                    'password': user.password,
                    'tenant_id': self.tenant.id,
                    'role_id': self.roles.first().id,
                    'confirm_password': "******"}

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

        self.assertFormError(res, "form", None, ['Passwords do not match.'])
Beispiel #20
0
 def __init__(self, request, *args, **kwargs):
     super(DownloadOpenRCForm, self).__init__(request, *args, **kwargs)
     # Populate tenant choices
     tenant_choices = []
     try:
         tenants = api.tenant_list(request)
     except:
         tenants = []
         exceptions.handle(request, _("Unable to retrieve project list."))
     for tenant in tenants:
         if tenant.enabled:
             tenant_choices.append((tenant.id, tenant.name))
     self.fields['tenant'].choices = tenant_choices
Beispiel #21
0
 def __init__(self, request, *args, **kwargs):
     super(DownloadOpenRCForm, self).__init__(request, *args, **kwargs)
     # Populate tenant choices
     tenant_choices = []
     try:
         tenants = api.tenant_list(request)
     except:
         tenants = []
         exceptions.handle(request, _("Unable to retrieve project list."))
     for tenant in tenants:
         if tenant.enabled:
             tenant_choices.append((tenant.id, tenant.name))
     self.fields['tenant'].choices = tenant_choices
Beispiel #22
0
    def test_update_validation_for_password_too_long(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), '1', admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())

        self.mox.ReplayAll()

        formData = {
            'method': 'UpdateUserForm',
            'id': user.id,
            'name': user.name,
            'email': user.email,
            'password': '******',
            'tenant_id': self.tenant.id,
            'confirm_password': '******'
        }

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

        self.assertFormError(res, "form", 'password',
                             ['Password must be between 8 and 18 characters.'])
Beispiel #23
0
    def test_create_with_password_mismatch(self):
        user = self.users.get(id="1")

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.get_default_role(IgnoreArg()).AndReturn(self.roles.first())

        self.mox.ReplayAll()

        formData = {
            "method": "CreateUserForm",
            "name": user.name,
            "email": user.email,
            "password": user.password,
            "tenant_id": self.tenant.id,
            "role_id": self.roles.first().id,
            "confirm_password": "******",
        }

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

        self.assertFormError(res, "form", None, ["Passwords do not match."])
Beispiel #24
0
    def test_create_with_password_mismatch(self):
        user = self.users.get(id="1")

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        api.keystone.role_list(IgnoreArg()).AndReturn(self.roles.list())
        api.keystone.get_default_role(IgnoreArg()) \
                    .AndReturn(self.roles.first())

        self.mox.ReplayAll()

        formData = {
            'method': 'CreateUserForm',
            'name': user.name,
            'email': user.email,
            'password': user.password,
            'tenant_id': self.tenant.id,
            'role_id': self.roles.first().id,
            'confirm_password': "******"
        }

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

        self.assertFormError(res, "form", None, ['Passwords do not match.'])
Beispiel #25
0
    def test_create_validation_for_password_too_long(self):
        user = self.users.get(id="1")

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        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",
            "name": user.name,
            "email": user.email,
            "password": "******",
            "tenant_id": self.tenant.id,
            "role_id": self.roles.first().id,
            "confirm_password": "******",
        }

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

        self.assertFormError(res, "form", "password", ["Password must be between 8 and 18 characters."])
Beispiel #26
0
    def test_update_validation_for_password_too_long(self):
        user = self.users.get(id="1")

        api.user_get(IsA(http.HttpRequest), '1',
                     admin=True).AndReturn(user)
        api.tenant_list(IgnoreArg(),
                        admin=True).AndReturn(self.tenants.list())

        self.mox.ReplayAll()

        formData = {'method': 'UpdateUserForm',
                    'id': user.id,
                    'name': user.name,
                    'email': user.email,
                    'password': '******',
                    'tenant_id': self.tenant.id,
                    'confirm_password': '******'}

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

        self.assertFormError(
                res, "form", 'password',
                ['Password must be between 8 and 18 characters.'])
Beispiel #27
0
    def test_create_validation_for_password_too_long(self):
        user = self.users.get(id="1")

        api.tenant_list(IgnoreArg(), admin=True).AndReturn(self.tenants.list())
        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',
                    'name': user.name,
                    'email': user.email,
                    'password': '******',
                    'tenant_id': self.tenant.id,
                    'role_id': self.roles.first().id,
                    'confirm_password': '******'}

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

        self.assertFormError(
            res, "form", 'password',
            ['Password must be between 8 and 18 characters.'])