예제 #1
0
    def test_bad_user_data(self):

        def format_path(values):
            values = list(values)
            msg = "%s%s" % (values[0],
                            ''.join(['[%r]' % i for i in values[1:]]))
            return msg

        _user = []
        _user_name = "F343jasdf"
        _user.append({"name12": _user_name,
                      "password12": "password"})
        try:
            self.dbaas.users.create(self.instance.id, _user)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(httpCode, 400,
                                 "Create user failed with code %s, "
                                 "exception %s" % (httpCode, e))
            err_1 = format_path(deque(('users', 0)))
            assert_contains(
                e.message,
                ["Validation error:",
                 "%(err_1)s 'name' is a required property" % {'err_1': err_1},
                 "%(err_1)s 'password' is a required property"
                 % {'err_1': err_1}])
예제 #2
0
    def test_bad_change_user_password(self):
        password = ""
        users = [{"name": password}]

        def _check_instance_status():
            inst = self.dbaas.instances.get(self.instance)
            if inst.status == "ACTIVE":
                return True
            else:
                return False

        poll_until(_check_instance_status)
        try:
            self.dbaas.users.change_passwords(self.instance, users)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(httpCode, 400,
                                 "Change usr/passwd failed with code %s, "
                                 "exception %s" % (httpCode, e))
            password = "******"
            assert_contains(
                e.message,
                ["Validation error: users[0] 'password' "
                 "is a required property",
                 "users[0]['name'] %s is too short" % password,
                 "users[0]['name'] %s does not match "
                 "'^.*[0-9a-zA-Z]+.*$'" % password])
예제 #3
0
 def test_bad_instance_data(self):
     databases = "foo"
     users = "bar"
     try:
         self.dbaas.instances.create("bad_instance",
                                     3,
                                     3,
                                     databases=databases,
                                     users=users)
     except Exception as e:
         resp, body = self.dbaas.client.last_response
         httpCode = resp.status
         asserts.assert_equal(
             httpCode, 400, "Create instance failed with code %s,"
             " exception %s" % (httpCode, e))
         if six.PY3:
             databases = "'%s'" % databases
             users = "'%s'" % users
         else:
             databases = "u'%s'" % databases
             users = "u'%s'" % users
         assert_contains(str(e), [
             "Validation error:",
             "instance['databases'] %s is not of type 'array'" % databases,
             "instance['users'] %s is not of type 'array'" % users,
             "instance['volume'] 3 is not of type 'object'"
         ])
예제 #4
0
    def test_bad_resize_vol_data(self):
        def _check_instance_status():
            inst = self.dbaas.instances.get(self.instance)
            if inst.status == "ACTIVE":
                return True
            else:
                return False

        poll_until(_check_instance_status)
        data = "bad data"
        try:
            self.dbaas.instances.resize_volume(self.instance.id, data)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(httpCode, 400,
                                 "Resize instance failed with code %s, "
                                 "exception %s" % (httpCode, e))
            data = "u'bad data'"
            assert_contains(
                e.message,
                ["Validation error:",
                 "resize['volume']['size'] %s is not valid under "
                 "any of the given schemas" % data,
                 "%s is not of type 'integer'" % data,
                 "%s does not match '^[0-9]+$'" % data])
예제 #5
0
    def test_bad_change_user_password(self):
        password = ""
        users = [{"name": password}]

        def _check_instance_status():
            inst = self.dbaas.instances.get(self.instance)
            if inst.status == "ACTIVE":
                return True
            else:
                return False

        poll_until(_check_instance_status)
        try:
            self.dbaas.users.change_passwords(self.instance, users)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(
                httpCode, 400, "Change usr/passwd failed with code %s, "
                "exception %s" % (httpCode, e))
            if six.PY3:
                password = "******" % password
            else:
                password = "******" % password
            assert_contains(str(e), [
                "Validation error: users[0] 'password' "
                "is a required property",
                "users[0]['name'] %s is too short" % password,
                "users[0]['name'] %s does not match "
                "'^.*[0-9a-zA-Z]+.*$'" % password
            ])
예제 #6
0
    def test_bad_body_datastore_create_instance(self):

        datastore = "*"
        datastore_version = "*"
        try:
            self.dbaas.instances.create("test_instance",
                                        3, {"size": 2},
                                        datastore=datastore,
                                        datastore_version=datastore_version)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(
                httpCode, 400, "Create instance failed with code %s, "
                "exception %s" % (httpCode, e))
            if six.PY3:
                datastore = "'%s'" % datastore
                datastore_version = "'%s'" % datastore_version
            else:
                datastore = "u'%s'" % datastore
                datastore_version = "u'%s'" % datastore_version
            assert_contains(str(e), [
                "Validation error:",
                "instance['datastore']['type']"
                " %s does not match"
                " '^.*[0-9a-zA-Z]+.*$'" % datastore,
                "instance['datastore']['version'] %s "
                "does not match '^.*[0-9a-zA-Z]+.*$'" % datastore_version
            ])
예제 #7
0
    def test_bad_resize_vol_data(self):
        def _check_instance_status():
            inst = self.dbaas.instances.get(self.instance)
            if inst.status == "ACTIVE":
                return True
            else:
                return False

        poll_until(_check_instance_status)
        data = "bad data"
        try:
            self.dbaas.instances.resize_volume(self.instance.id, data)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(
                httpCode, 400, "Resize instance failed with code %s, "
                "exception %s" % (httpCode, e))
            if six.PY3:
                data = "'bad data'"
            else:
                data = "u'bad data'"
            assert_contains(str(e), [
                "Validation error:",
                "resize['volume']['size'] %s is not valid under "
                "any of the given schemas" % data,
                "%s is not of type 'integer'" % data,
                "%s does not match '^0*[1-9]+[0-9]*$'" % data
            ])
예제 #8
0
    def test_bad_user_data(self):
        def format_path(values):
            values = list(values)
            msg = "%s%s" % (values[0], ''.join(
                ['[%r]' % i for i in values[1:]]))
            return msg

        _user = []
        _user_name = "F343jasdf"
        _user.append({"name12": _user_name, "password12": "password"})
        try:
            self.dbaas.users.create(self.instance.id, _user)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(
                httpCode, 400, "Create user failed with code %s, "
                "exception %s" % (httpCode, e))
            err_1 = format_path(deque(('users', 0)))
            assert_contains(str(e), [
                "Validation error:",
                "%(err_1)s 'name' is a required property" % {
                    'err_1': err_1
                },
                "%(err_1)s 'password' is a required property" % {
                    'err_1': err_1
                }
            ])
예제 #9
0
 def test_bad_instance_data(self):
     databases = "foo"
     users = "bar"
     try:
         self.dbaas.instances.create("bad_instance", 3, 3,
                                     databases=databases, users=users)
     except Exception as e:
         resp, body = self.dbaas.client.last_response
         httpCode = resp.status
         asserts.assert_equal(httpCode, 400,
                              "Create instance failed with code %s,"
                              " exception %s" % (httpCode, e))
         databases = "u'foo'"
         users = "u'bar'"
         assert_contains(
             e.message,
             ["Validation error:",
              "instance['databases'] %s is not of type 'array'" % databases,
              "instance['users'] %s is not of type 'array'" % users,
              "instance['volume'] 3 is not of type 'object'"])
예제 #10
0
    def test_bad_body_datastore_create_instance(self):

        datastore = "*"
        datastore_version = "*"
        try:
            self.dbaas.instances.create(
                "test_instance", 3, {"size": 2}, datastore=datastore, datastore_version=datastore_version
            )
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(httpCode, 400, "Create instance failed with code %s, " "exception %s" % (httpCode, e))
            assert_contains(
                e.message,
                [
                    "Validation error:",
                    "instance['datastore']['type']" " u'%s' does not match" " '^.*[0-9a-zA-Z]+.*$'" % datastore,
                    "instance['datastore']['version'] u'%s' " "does not match '^.*[0-9a-zA-Z]+.*$'" % datastore_version,
                ],
            )
예제 #11
0
    def test_bad_body_flavorid_create_instance(self):

        flavorId = ["?"]
        try:
            self.dbaas.instances.create("test_instance", flavorId, 2)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(
                httpCode, 400, "Create instance failed with code %s, "
                "exception %s" % (httpCode, e))
            flavorId = [u'?']
            assert_contains(str(e), [
                "Validation error:",
                "instance['flavorRef'] %s is not valid "
                "under any of the given schemas" % flavorId,
                "%s is not of type 'string'" % flavorId,
                "%s is not of type 'string'" % flavorId,
                "%s is not of type 'integer'" % flavorId,
                "instance['volume'] 2 is not of type 'object'"
            ])
예제 #12
0
    def test_bad_body_flavorid_create_instance(self):

        flavorId = ["?"]
        try:
            self.dbaas.instances.create("test_instance", flavorId, 2)
        except Exception as e:
            resp, body = self.dbaas.client.last_response
            httpCode = resp.status
            asserts.assert_equal(httpCode, 400, "Create instance failed with code %s, " "exception %s" % (httpCode, e))
            flavorId = [u"?"]
            assert_contains(
                e.message,
                [
                    "Validation error:",
                    "instance['flavorRef'] %s is not valid " "under any of the given schemas" % flavorId,
                    "%s is not of type 'string'" % flavorId,
                    "%s is not of type 'string'" % flavorId,
                    "%s is not of type 'integer'" % flavorId,
                    "instance['volume'] 2 is not of type 'object'",
                ],
            )