aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_http_callback.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/tests/test_http_callback.py')
-rw-r--r--mediagoblin/tests/test_http_callback.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/mediagoblin/tests/test_http_callback.py b/mediagoblin/tests/test_http_callback.py
index f7249229..e2c85d0d 100644
--- a/mediagoblin/tests/test_http_callback.py
+++ b/mediagoblin/tests/test_http_callback.py
@@ -20,28 +20,27 @@ from urlparse import urlparse, parse_qs
from mediagoblin import mg_globals
from mediagoblin.tools import processing
-from mediagoblin.tests.tools import get_app, fixture_add_user
+from mediagoblin.tests.tools import fixture_add_user
from mediagoblin.tests.test_submission import GOOD_PNG
from mediagoblin.tests import test_oauth as oauth
class TestHTTPCallback(object):
- def setup(self):
- self.app = get_app(dump_old_app=False)
+ def _setup(self, test_app):
self.db = mg_globals.database
self.user_password = u'secret'
self.user = fixture_add_user(u'call_back', self.user_password)
- self.login()
+ self.login(test_app)
- def login(self):
- self.app.post('/auth/login/', {
+ def login(self, testapp):
+ testapp.post('/auth/login/', {
'username': self.user.username,
'password': self.user_password})
- def get_access_token(self, client_id, client_secret, code):
- response = self.app.get('/oauth/access_token', {
+ def get_access_token(self, testapp, client_id, client_secret, code):
+ response = testapp.get('/oauth/access_token', {
'code': code,
'client_id': client_id,
'client_secret': client_secret})
@@ -50,13 +49,15 @@ class TestHTTPCallback(object):
return response_data['access_token']
- def test_callback(self):
+ def test_callback(self, test_app):
''' Test processing HTTP callback '''
+ self._setup(test_app)
self.oauth = oauth.TestOAuth()
- self.oauth.setup()
+ self.oauth._setup(test_app)
- redirect, client_id = self.oauth.test_4_authorize_confidential_client()
+ redirect, client_id = self.oauth.test_4_authorize_confidential_client(
+ test_app)
code = parse_qs(urlparse(redirect.location).query)['code'][0]
@@ -65,11 +66,11 @@ class TestHTTPCallback(object):
client_secret = client.secret
- access_token = self.get_access_token(client_id, client_secret, code)
+ access_token = self.get_access_token(test_app, client_id, client_secret, code)
callback_url = 'https://foo.example?secrettestmediagoblinparam'
- res = self.app.post('/api/submit?client_id={0}&access_token={1}\
+ res = test_app.post('/api/submit?client_id={0}&access_token={1}\
&client_secret={2}'.format(
client_id,
access_token,