예제 #1
0
    def test_drop_should_returns_405_when_method_is_not_delete(self):
        request = RequestFactory().get("/")
        response = drop_user(request)
        self.assertEqual(405, response.status_code)

        request = RequestFactory().put("/")
        response = drop_user(request)
        self.assertEqual(405, response.status_code)

        request = RequestFactory().post("/")
        response = drop_user(request)
        self.assertEqual(405, response.status_code)
예제 #2
0
    def test_drop_should_return_405_when_method_is_not_delete(self):
        request = RequestFactory().get("/")
        response = drop_user(request)
        self.assertEqual(405, response.status_code)

        request = RequestFactory().put("/")
        response = drop_user(request)
        self.assertEqual(405, response.status_code)

        request = RequestFactory().post("/")
        response = drop_user(request)
        self.assertEqual(405, response.status_code)
예제 #3
0
 def test_drop_should_return_500_and_error_msg_in_body(self):
     instance = Instance.objects.create(name="fails", host="127.0.0.1")
     try:
         request = RequestFactory().delete("/")
         response = drop_user(request, "fails", "hostname")
         self.assertEqual(500, response.status_code)
         content = "Operation DROP USER failed for 'fails'@'%'"
         self.assertEqual(content, response.content)
     finally:
         instance.delete()
예제 #4
0
 def test_drop_should_return_500_and_error_msg_in_body(self):
     instance = Instance.objects.create(name="fails", host="127.0.0.1")
     try:
         request = RequestFactory().delete("/")
         response = drop_user(request, "fails", "hostname")
         self.assertEqual(500, response.status_code)
         content = "Operation DROP USER failed for 'fails'@'%'"
         self.assertEqual(content, response.content)
     finally:
         instance.delete()
예제 #5
0
    def test_drop_user_fom_custom_service_host(self):
        db = DatabaseManager("ciclops", "127.0.0.1")
        db.create_user("ciclops", "localhost")

        request = RequestFactory().delete("/ciclops", {"service_host": "127.0.0.1"})
        response = drop_user(request, "ciclops", "localhost")
        self.assertEqual(200, response.status_code)

        self.cursor.execute("select User, Host FROM mysql.user WHERE User='******' AND Host='localhost'")
        row = self.cursor.fetchone()
        self.assertFalse(row)
예제 #6
0
 def test_drop_user_from_shared_instance(self):
     settings.SHARED_SERVER = "127.0.0.1"
     instance = Instance.objects.create(name="used", shared=True)
     try:
         db = DatabaseManager("used")
         db.create_user("used", "127.0.0.1")
         request = RequestFactory().delete("/used")
         response = drop_user(request, "used", "127.0.0.1")
         self.assertEqual(200, response.status_code)
         sql = "select User, Host FROM mysql.user " +\
               "WHERE User='******' AND Host='%'"
         self.cursor.execute(sql)
         row = self.cursor.fetchone()
         self.assertIsNone(row)
     finally:
         instance.delete()
예제 #7
0
 def test_drop_user_from_shared_instance(self):
     settings.SHARED_SERVER = "127.0.0.1"
     instance = Instance.objects.create(name="used", shared=True)
     try:
         db = DatabaseManager("used")
         db.create_user("used", "127.0.0.1")
         request = RequestFactory().delete("/used")
         response = drop_user(request, "used", "127.0.0.1")
         self.assertEqual(200, response.status_code)
         sql = "select User, Host FROM mysql.user " +\
               "WHERE User='******' AND Host='%'"
         self.cursor.execute(sql)
         row = self.cursor.fetchone()
         self.assertIsNone(row)
     finally:
         instance.delete()
예제 #8
0
    def test_drop_user(self):
        instance = Instance.objects.create(name="ciclops", host="127.0.0.1")
        try:
            db = DatabaseManager("ciclops")
            db.create_user("ciclops", "localhost")

            request = RequestFactory().delete("/ciclops")
            response = drop_user(request, "ciclops", "localhost")
            self.assertEqual(200, response.status_code)

            sql = "select User, Host FROM mysql.user " +\
                  "WHERE User='******' AND Host='%'"
            self.cursor.execute(sql)
            row = self.cursor.fetchone()
            self.assertFalse(row)
        finally:
            instance.delete()
예제 #9
0
    def test_drop_user(self):
        instance = Instance.objects.create(name="ciclops", host="127.0.0.1")
        try:
            db = DatabaseManager("ciclops")
            db.create_user("ciclops", "localhost")

            request = RequestFactory().delete("/ciclops")
            response = drop_user(request, "ciclops", "localhost")
            self.assertEqual(200, response.status_code)

            sql = "select User, Host FROM mysql.user " +\
                  "WHERE User='******' AND Host='%'"
            self.cursor.execute(sql)
            row = self.cursor.fetchone()
            self.assertFalse(row)
        finally:
            instance.delete()
예제 #10
0
 def test_drop_user_return_404_if_the_instance_does_not_exist(self):
     request = RequestFactory().delete("/ciclops")
     response = drop_user(request, "ciclops", "localhost")
     self.assertEqual(404, response.status_code)
     self.assertEqual("Instance not found.", response.content)
예제 #11
0
 def test_drop_should_returns_500_and_error_msg_in_body(self):
     request = RequestFactory().delete("/")
     response = drop_user(request, "doesnotexists", "hostname")
     self.assertEqual(500, response.status_code)
     self.assertEqual("Operation DROP USER failed for 'doesnotexists'@'hostname'", response.content)
예제 #12
0
 def test_drop_user_return_404_if_the_instance_does_not_exist(self):
     request = RequestFactory().delete("/ciclops")
     response = drop_user(request, "ciclops", "localhost")
     self.assertEqual(404, response.status_code)
     self.assertEqual("Instance not found.", response.content)