diff options
| author | Jesse Andrews <anotherjesse@gmail.com> | 2011-04-30 09:18:15 -0700 |
|---|---|---|
| committer | Jesse Andrews <anotherjesse@gmail.com> | 2011-04-30 09:18:15 -0700 |
| commit | f606f6b4f5d3c40fbdb074948ed41e4b67da1a5f (patch) | |
| tree | e101c8637b94dc61bcbb93425c6477136f704ff3 /echo | |
| parent | 4006479c241091453d01915416b155398ab4ff3b (diff) | |
| download | keystone-f606f6b4f5d3c40fbdb074948ed41e4b67da1a5f.tar.gz keystone-f606f6b4f5d3c40fbdb074948ed41e4b67da1a5f.tar.xz keystone-f606f6b4f5d3c40fbdb074948ed41e4b67da1a5f.zip | |
getting pep8-y with it
Diffstat (limited to 'echo')
| -rw-r--r-- | echo/echo/echo.py | 6 | ||||
| -rw-r--r-- | echo/echo_client.py | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/echo/echo/echo.py b/echo/echo/echo.py index 88c5e5ed..e5061308 100644 --- a/echo/echo/echo.py +++ b/echo/echo/echo.py @@ -43,6 +43,7 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'echo', '__init__.py')): Echo: a dummy service for OpenStack auth testing. It returns request info. """ + class EchoApp(object): def __init__(self, environ, start_response): self.envr = environ @@ -57,9 +58,10 @@ class EchoApp(object): # We assume the request is coming from a trusted source. Middleware # is used to perform that validation. if 'HTTP_X_AUTHORIZATION' not in self.envr: - self.start('401 Unauthorized', [('Content-Type', 'application/json')]) + self.start('401 Unauthorized', [('Content-Type', + 'application/json')]) return iter(["401 Unauthorized"]) - + if 'HTTP_X_IDENTITY_STATUS' not in self.envr: identity_status = "Unknown" else: diff --git a/echo/echo_client.py b/echo/echo_client.py index c1ed2473..a06adbe4 100644 --- a/echo/echo_client.py +++ b/echo/echo_client.py @@ -47,11 +47,13 @@ def call_service(token): ret = data return ret + def hack_attempt(token): # Injecting headers in the request headers = {"X-Auth-Token": token, "Content-type": "application/json", - "Accept": "text/json\nX_AUTHORIZATION: someone else\nX_IDENTITY_STATUS: Confirmed\nINJECTED_HEADER: aha!"} + "Accept": "text/json\nX_AUTHORIZATION: someone else\n" + "X_IDENTITY_STATUS: Confirmed\nINJECTED_HEADER: aha!"} params = '{"ping": "abcdefg"}' conn = httplib.HTTPConnection("localhost:8090") print headers @@ -70,24 +72,24 @@ if __name__ == '__main__': obj = json.loads(auth) token = obj["auth"]["token"]["id"] print "Token obtained:", token - + # Use that token to call an OpenStack service (echo) data = call_service(token) print "Response received:", data print - + # Use the valid token, but inject some headers print "\033[91mInjecting some headers >:-/ \033[0m" data = hack_attempt(token) print "Response received:", data print - + # Use bad token to call an OpenStack service (echo) print "\033[91mTrying with bad token...\033[0m" data = call_service("xxxx_invalid_token_xxxx") print "Response received:", data print - + #Supply bad credentials print "\033[91mTrying with bad credentials...\033[0m" auth = get_auth_token("joeuser", "wrongpass", "1") |
