Exemplo n.º 1
0
 def runTest(self):
     """This function will update foreign server present under test
     database. """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_name)
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     db_user = self.server["username"]
     data = {
         "name":
         db_user,
         "um_options": [],
         "umoptions": [{
             "umoption": "user",
             "umvalue": self.server["username"]
         }, {
             "umoption": "password",
             "umvalue": self.server["db_password"]
         }]
     }
     response = self.tester.post(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.fdw_id) + '/' +
         str(self.fsrv_id) + '/',
         data=json.dumps(data),
         content_type='html/json')
     self.assertEquals(response.status_code, 200)
Exemplo n.º 2
0
    def runTest(self):
        """This function will delete user mapping present under test
         database. """
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con["info"] == "Database connected.":
            raise Exception("Could not connect to database.")
        fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                            self.fdw_name)
        if not fdw_response:
            raise Exception("Could not find FDW.")
        fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                               self.fsrv_name)
        if not fsrv_response:
            raise Exception("Could not find FSRV.")
        um_response = um_utils.verify_user_mapping(self.server, self.db_name,
                                                   self.fsrv_name)
        if not um_response:
            raise Exception("Could not find user mapping.")
        self.data = {'ids': [self.um_id]}
        if self.is_positive_test:
            delete_response = self.delete_multiple()

        actual_response_code = delete_response.status_code
        expected_response_code = self.expected_data['status_code']
        self.assertEqual(actual_response_code, expected_response_code)
Exemplo n.º 3
0
    def runTest(self):
        """This function will fetch foreign server present under test
         database."""
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con["info"] == "Database connected.":
            raise Exception("Could not connect to database.")
        fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                            self.fdw_name)
        if not fdw_response:
            raise Exception("Could not find FDW.")
        fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                               self.fsrv_name)
        if not fsrv_response:
            raise Exception("Could not find FSRV.")

        if self.is_positive_test:
            delete_response = self.delete_foreign_server()
        else:
            if hasattr(self, "internal_server_error"):
                with patch(self.mock_data["function_name"],
                           return_value=eval(self.mock_data["return_value"])):
                    delete_response = self.delete_foreign_server()

            if hasattr(self, "wrong_foreign_server_id"):
                self.fsrv_id = 99999
                delete_response = self.delete_foreign_server()

        actual_response_code = delete_response.status_code
        expected_response_code = self.expected_data['status_code']
        self.assertEquals(actual_response_code, expected_response_code)
Exemplo n.º 4
0
 def runTest(self):
     """This function will update foreign server present under test
     database."""
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_name)
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     data = {
         "description": "This is foreign server update comment",
         "id": self.fsrv_id
     }
     put_response = self.tester.put(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.fdw_id) + '/' +
         str(self.fsrv_id),
         data=json.dumps(data),
         follow_redirects=True)
     self.assertEquals(put_response.status_code, 200)
 def runTest(self):
     """This function will update foreign server present under test
     database"""
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_name)
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     um_response = um_utils.verify_user_mapping(self.server, self.db_name,
                                                self.fsrv_name)
     if not um_response:
         raise Exception("Could not find user mapping.")
     data = {
         "id": self.um_id,
         "umoptions": {
             "changed": [{
                 "umoption": "user",
                 "umvalue": "public"
             }]
         }
     }
     put_response = self.tester.put(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.fdw_id) + '/' +
         str(self.fsrv_id) + '/' + str(self.um_id),
         data=json.dumps(data),
         follow_redirects=True)
     self.assertEquals(put_response.status_code, 200)
Exemplo n.º 6
0
    def runTest(self):
        """This function will update foreign server present under test
        database."""
        db_con = database_utils.connect_database(self,
                                                 utils.SERVER_GROUP,
                                                 self.server_id,
                                                 self.db_id)
        if not db_con["info"] == "Database connected.":
            raise Exception("Could not connect to database.")
        fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                            self.fdw_name)
        if not fdw_response:
            raise Exception("Could not find FDW.")
        fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                               self.fsrv_name)
        if not fsrv_response:
            raise Exception("Could not find FSRV.")
        self.test_data["id"] = self.fsrv_id

        if self.is_positive_test:
            put_response = self.update_fsrv()

        else:
            if hasattr(self, "error_in_db"):
                with patch(self.mock_data["function_name"],
                           side_effect=eval(self.mock_data["return_value"])):
                    put_response = self.update_fsrv()

        actual_response_code = put_response.status_code
        expected_response_code = self.expected_data['status_code']
        self.assertEqual(actual_response_code, expected_response_code)
 def runTest(self):
     """This function will delete user mapping present under test
      database. """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_name)
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     um_response = um_utils.verify_user_mapping(self.server, self.db_name,
                                                self.fsrv_name)
     if not um_response:
         raise Exception("Could not find user mapping.")
     delete_response = self.tester.delete(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.fdw_id) + '/' +
         str(self.fsrv_id) + '/' + str(self.um_id),
         follow_redirects=True)
     self.assertEquals(delete_response.status_code, 200)
 def runTest(self):
     """This function will fetch foreign server present under test
      database."""
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_names[0])
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_names[1])
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     data = {'ids': self.fsrv_ids}
     delete_response = self.tester.delete(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.fdw_id) + "/",
         data=json.dumps(data),
         content_type='html/json',
         follow_redirects=True)
     self.assertEquals(delete_response.status_code, 200)
Exemplo n.º 9
0
 def runTest(self):
     """This function will update foreign server present under test
     database."""
     db_con = database_utils.connect_database(self,
                                              utils.SERVER_GROUP,
                                              self.server_id,
                                              self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                            self.fsrv_name)
     if not fsrv_response:
         raise Exception("Could not find FSRV.")
     data = {"description": "This is foreign server update comment",
             "id": self.fsrv_id}
     put_response = self.tester.put(
         self.url + str(utils.SERVER_GROUP) + '/' +
         str(self.server_id) + '/' + str(self.db_id) +
         '/' + str(self.fdw_id) + '/' +
         str(self.fsrv_id), data=json.dumps(data),
         follow_redirects=True)
     self.assertEquals(put_response.status_code, 200)
Exemplo n.º 10
0
 def runTest(self):
     """This function will fetch foreign data wrapper present under test
      database."""
     db_con = database_utils.connect_database(self,
                                              utils.SERVER_GROUP,
                                              self.server_id,
                                              self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     db_user = self.server["username"]
     data = {
         "fsrvacl": [
             {
                 "grantee": db_user,
                 "grantor": db_user,
                 "privileges":
                     [
                         {
                             "privilege_type": "U",
                             "privilege": "true",
                             "with_grant": "false"
                         }
                     ]
             }
         ],
         "fsrvoptions": [
             {
                 "fsrvoption": "host",
                 "fsrvvalue": self.server['host']
             },
             {
                 "fsrvoption": "port",
                 "fsrvvalue": str(self.server['port'])
             },
             {
                 "fsrvoption": "dbname",
                 "fsrvvalue": self.db_name
             }
         ],
         "fsrvowner": db_user,
         "name": "test_fsrv_add_%s" % (str(uuid.uuid4())[1:8])
     }
     response = self.tester.post(
         self.url + str(utils.SERVER_GROUP) + '/' +
         str(self.server_id) + '/' + str(self.db_id) +
         '/' + str(self.fdw_id) + '/',
         data=json.dumps(data),
         content_type='html/json')
     self.assertEquals(response.status_code, 200)
 def runTest(self):
     """This function will fetch foreign data wrapper present under test
      database."""
     db_con = database_utils.connect_database(self,
                                              utils.SERVER_GROUP,
                                              self.server_id,
                                              self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     db_user = self.server["username"]
     data = {
         "fsrvacl": [
             {
                 "grantee": db_user,
                 "grantor": db_user,
                 "privileges":
                     [
                         {
                             "privilege_type": "U",
                             "privilege": "true",
                             "with_grant": "false"
                         }
                     ]
             }
         ],
         "fsrvoptions": [
             {
                 "fsrvoption": "host",
                 "fsrvvalue": self.server['host']
             },
             {
                 "fsrvoption": "port",
                 "fsrvvalue": str(self.server['port'])
             },
             {
                 "fsrvoption": "dbname",
                 "fsrvvalue": self.db_name
             }
         ],
         "fsrvowner": db_user,
         "name": "test_fsrv_add_%s" % (str(uuid.uuid4())[1:8])
     }
     response = self.tester.post(
         self.url + str(utils.SERVER_GROUP) + '/' +
         str(self.server_id) + '/' + str(self.db_id) + '/'
         + str(self.fdw_id) + '/', data=json.dumps(data),
         content_type='html/json')
     self.assertEquals(response.status_code, 200)
Exemplo n.º 12
0
    def runTest(self):
        """This function will fetch foreign server and add user mappping
         present under test database. """
        db_con = database_utils.connect_database(self,
                                                 utils.SERVER_GROUP,
                                                 self.server_id,
                                                 self.db_id)
        if not db_con["info"] == "Database connected.":
            raise Exception("Could not connect to database.")
        fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                            self.fdw_name)
        if not fdw_response:
            raise Exception("Could not find FDW.")
        fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                               self.fsrv_name)
        if not fsrv_response:
            raise Exception("Could not find FSRV.")
        db_user = self.server["username"]
        self.data = user_utils.get_um_data(db_user, self.server)
        if self.is_positive_test:
            response = self.create_user_mapping()

        else:
            if hasattr(self, "error_fsrv_id"):
                self.fsrv_id = 99999
                response = self.create_user_mapping()

            if hasattr(self, "internal_server_error"):
                return_value_object = eval(self.mock_data["return_value"])
                with patch(self.mock_data["function_name"],
                           side_effect=[return_value_object]):
                    response = self.create_user_mapping()

            if hasattr(self, "missing_parameter"):
                del self.data['name']
                response = self.create_user_mapping()

            if hasattr(self, "error_in_db"):
                return_value_object = eval(self.mock_data["return_value"])
                with patch(self.mock_data["function_name"],
                           side_effect=[return_value_object]):
                    response = self.create_user_mapping()

        actual_response_code = response.status_code
        expected_response_code = self.expected_data['status_code']
        self.assertEqual(actual_response_code, expected_response_code)
Exemplo n.º 13
0
 def runTest(self):
     """This function will fetch foreign server present under test
     database."""
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = self.tester.get(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.fdw_id) + '/' +
         str(self.fsrv_id),
         content_type='html/json')
     self.assertEquals(fsrv_response.status_code, 200)
Exemplo n.º 14
0
 def runTest(self):
     """This function will fetch foreign server present under test
     database."""
     db_con = database_utils.connect_database(self,
                                              utils.SERVER_GROUP,
                                              self.server_id,
                                              self.db_id)
     if not db_con["info"] == "Database connected.":
         raise Exception("Could not connect to database.")
     fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                         self.fdw_name)
     if not fdw_response:
         raise Exception("Could not find FDW.")
     fsrv_response = self.tester.get(
         self.url + str(utils.SERVER_GROUP) + '/' +
         str(self.server_id) + '/' + str(self.db_id) +
         '/' + str(self.fdw_id) + '/' + str(self.fsrv_id),
         content_type='html/json')
     self.assertEquals(fsrv_response.status_code, 200)
Exemplo n.º 15
0
    def runTest(self):
        """This function will fetch foreign server msql present under test
         database."""
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con["info"] == "Database connected.":
            raise Exception("Could not connect to database.")
        fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                            self.fdw_name)
        if not fdw_response:
            raise Exception("Could not find FDW.")
        fsrv_response = fsrv_utils.verify_fsrv(self.server, self.db_name,
                                               self.fsrv_name)
        if not fsrv_response:
            raise Exception("Could not find FSRV.")

        if self.is_positive_test:
            response = self.msql_foreign_server()

        actual_response_code = response.status_code
        expected_response_code = self.expected_data['status_code']
        self.assertEqual(actual_response_code, expected_response_code)
Exemplo n.º 16
0
    def runTest(self):
        """This function will fetch user mapping present under test
        database"""
        db_con = database_utils.connect_database(self,
                                                 utils.SERVER_GROUP,
                                                 self.server_id,
                                                 self.db_id)
        if not db_con["info"] == "Database connected.":
            raise Exception("Could not connect to database.")
        fdw_response = fdw_utils.verify_fdw(self.server, self.db_name,
                                            self.fdw_name)
        if not fdw_response:
            raise Exception("Could not find FDW.")
        fsrv_response = fsrv_utils.verify_fsrv(self.server,
                                               self.db_name,
                                               self.fsrv_name)
        if not fsrv_response:
            raise Exception("Could not find FSRV.")
        um_response = um_utils.verify_user_mapping(self.server, self.db_name,
                                                   self.fsrv_name)
        if not um_response:
            raise Exception("Could not find user mapping.")

        if self.is_positive_test:
            response = self.sql_user_mapping()
        else:
            if hasattr(self, "internal_server_error"):
                return_value_object = eval(self.mock_data["return_value"])
                with patch(self.mock_data["function_name"],
                           side_effect=[return_value_object]):
                    response = self.sql_user_mapping()

            if hasattr(self, "wrong_um_id"):
                self.um_id = 99999
                response = self.sql_user_mapping()

        actual_response_code = response.status_code
        expected_response_code = self.expected_data['status_code']
        self.assertEquals(actual_response_code, expected_response_code)