Beispiel #1
0
 def test_delete_on_delete(self):
     self.assertEqual(
         http_call(
             "DELETE",
             "http://localhost/app/++services++json/delete").getBody(),
         b"DELETED !!",
     )
Beispiel #2
0
 def test_get_on_service(self):
     self.assertEqual(
         json.loads(
             http_call(
                 "GET",
                 "http://localhost/app/++services++json/dump").getBody()),
         {"SomeKey": "SomeValue"},
     )
Beispiel #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"),
         ],
     )
Beispiel #4
0
 def not_existing_post(self):
     with self.assertRaces(NotImplementedError):
         http_call('POST', 'http://locahost/app')
Beispiel #5
0
 def test_existing_get(self):
     self.assertEqual(
         http_call("GET", "http://localhost/app").getBody(), b"HI FROM GET")
Beispiel #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")
Beispiel #7
0
 def test_with_cors(self):
     response = http_call("GET",
                          "http://localhost/authapp",
                          Authorization="Bearer blablub")
     print(response.getBody())
Beispiel #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")
Beispiel #9
0
 def test_unknown_service(self):
     with self.assertRaises(LookupError):
         http_call("OPTIONS", "http://localhost/app/++services++test")
Beispiel #10
0
 def test_not_implemnted_service(self):
     with self.assertRaises(NotImplementedError):
         http_call("OPTIONS", "http://localhost/app/++services++")