2020from threema .gateway import e2e
2121from threema .gateway .key import Key
2222
23+ # Turn off deprecation warnings for now
24+ # TODO: Port code to async/await
25+ os .environ ['PYTHONWARNINGS' ] = 'ignore'
26+
2327_res_path = os .path .normpath (os .path .join (
2428 os .path .abspath (__file__ ), os .pardir , 'res' ))
2529
@@ -85,7 +89,7 @@ def __init__(self):
8589 @asyncio .coroutine
8690 def pubkeys (self , request ):
8791 key = request .match_info ['key' ]
88- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
92+ from_ , secret = request .query ['from' ], request .query ['secret' ]
8993 if (from_ , secret ) not in pytest .msgapi .api_identities :
9094 return web .Response (status = 401 )
9195 elif len (key ) != 8 :
@@ -99,7 +103,7 @@ def pubkeys(self, request):
99103 @asyncio .coroutine
100104 def lookup_phone (self , request ):
101105 phone = request .match_info ['phone' ]
102- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
106+ from_ , secret = request .query ['from' ], request .query ['secret' ]
103107 if (from_ , secret ) not in pytest .msgapi .api_identities :
104108 return web .Response (status = 401 )
105109 elif not phone .isdigit ():
@@ -111,7 +115,7 @@ def lookup_phone(self, request):
111115 @asyncio .coroutine
112116 def lookup_phone_hash (self , request ):
113117 phone_hash = request .match_info ['phone_hash' ]
114- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
118+ from_ , secret = request .query ['from' ], request .query ['secret' ]
115119 hash_ = '98b05f6eda7a878f6f016bdcdc9db6eb61a6b190e814ff787142115af144214c'
116120 if (from_ , secret ) not in pytest .msgapi .api_identities :
117121 return web .Response (status = 401 )
@@ -127,7 +131,7 @@ def lookup_phone_hash(self, request):
127131 @asyncio .coroutine
128132 def lookup_email (self , request ):
129133 email = request .match_info ['email' ]
130- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
134+ from_ , secret = request .query ['from' ], request .query ['secret' ]
131135 if (from_ , secret ) not in pytest .msgapi .api_identities :
132136 return web .Response (status = 401 )
133137 elif email == 'echoecho@example.com' :
@@ -137,7 +141,7 @@ def lookup_email(self, request):
137141 @asyncio .coroutine
138142 def lookup_email_hash (self , request ):
139143 email_hash = request .match_info ['email_hash' ]
140- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
144+ from_ , secret = request .query ['from' ], request .query ['secret' ]
141145 hash_ = '45a13d422b40f81936a9987245d3f6d9064c90607273af4f578246b4484669e2'
142146 if (from_ , secret ) not in pytest .msgapi .api_identities :
143147 return web .Response (status = 401 )
@@ -153,7 +157,7 @@ def lookup_email_hash(self, request):
153157 @asyncio .coroutine
154158 def capabilities (self , request ):
155159 id_ = request .match_info ['id' ]
156- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
160+ from_ , secret = request .query ['from' ], request .query ['secret' ]
157161 if (from_ , secret ) not in pytest .msgapi .api_identities :
158162 return web .Response (status = 401 )
159163 elif id_ == 'ECHOECHO' :
@@ -164,7 +168,7 @@ def capabilities(self, request):
164168
165169 @asyncio .coroutine
166170 def credits (self , request ):
167- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
171+ from_ , secret = request .query ['from' ], request .query ['secret' ]
168172 if (from_ , secret ) not in pytest .msgapi .api_identities :
169173 return web .Response (status = 401 )
170174 return web .Response (body = b'100' )
@@ -227,7 +231,7 @@ def upload_blob(self, request):
227231 data = (yield from request .post ())
228232
229233 # Check API identity
230- api_identity = (request .GET ['from' ], request .GET ['secret' ])
234+ api_identity = (request .query ['from' ], request .query ['secret' ])
231235 if api_identity not in pytest .msgapi .api_identities :
232236 return web .Response (status = 401 )
233237 except KeyError :
@@ -244,7 +248,7 @@ def upload_blob(self, request):
244248 blob_id = hashlib .md5 (blob ).hexdigest ()
245249
246250 # Process
247- if request .GET ['from' ] == pytest .msgapi .nocredit_id :
251+ if request .query ['from' ] == pytest .msgapi .nocredit_id :
248252 return web .Response (status = 402 )
249253 elif len (blob ) == 0 :
250254 return web .Response (status = 400 )
@@ -261,7 +265,7 @@ def download_blob(self, request):
261265 blob_id = request .match_info ['blob_id' ]
262266
263267 # Check API identity
264- from_ , secret = request .GET ['from' ], request .GET ['secret' ]
268+ from_ , secret = request .query ['from' ], request .query ['secret' ]
265269 if (from_ , secret ) not in pytest .msgapi .api_identities :
266270 return web .Response (status = 401 )
267271
0 commit comments