예제 #1
0
 def test_delete_on_delete(self):
     self.assertEqual(
         http_call(
             "DELETE",
             "http://localhost/app/++services++json/delete").getBody(),
         b"DELETED !!",
     )
예제 #2
0
 def test_get_on_service(self):
     self.assertEqual(
         json.loads(
             http_call(
                 "GET",
                 "http://localhost/app/++services++json/dump").getBody()),
         {"SomeKey": "SomeValue"},
     )
예제 #3
0
 def test_with_cors(self):
     response = http_call("OPTIONS", "http://localhost/app")
     self.assertEqual(
         response.getHeaders(),
         [
             ("Access-Control-Allow-Methods", "PUT"),
             ("Access-Control-Allow-Origin", "http://localhost:8080"),
             ("Content-Length", "0"),
         ],
     )
예제 #4
0
 def not_existing_post(self):
     with self.assertRaces(NotImplementedError):
         http_call('POST', 'http://locahost/app')
예제 #5
0
 def test_existing_get(self):
     self.assertEqual(
         http_call("GET", "http://localhost/app").getBody(), b"HI FROM GET")
예제 #6
0
    def test_without_cors(self):
        import zope.security.interfaces

        with self.assertRaises(zope.security.interfaces.Unauthorized):
            http_call("OPTIONS", "http://localhost/no_cors_app")
예제 #7
0
 def test_with_cors(self):
     response = http_call("GET",
                          "http://localhost/authapp",
                          Authorization="Bearer blablub")
     print(response.getBody())
예제 #8
0
 def test_unauth(self):
     import zope.security.interfaces
     with self.assertRaises(zope.security.interfaces.Unauthorized):
         http_call("OPTIONS", "http://localhost/app/++services++json/dump")
예제 #9
0
 def test_unknown_service(self):
     with self.assertRaises(LookupError):
         http_call("OPTIONS", "http://localhost/app/++services++test")
예제 #10
0
 def test_not_implemnted_service(self):
     with self.assertRaises(NotImplementedError):
         http_call("OPTIONS", "http://localhost/app/++services++")