Fixes tests
authorxray7224 <xray7224@googlemail.com>
Sun, 14 Jul 2013 18:00:52 +0000 (19:00 +0100)
committerxray7224 <xray7224@googlemail.com>
Sun, 14 Jul 2013 18:00:52 +0000 (19:00 +0100)
mediagoblin/federation/routing.py
mediagoblin/federation/views.py
mediagoblin/plugins/api/views.py
mediagoblin/plugins/oauth/__init__.py
mediagoblin/plugins/oauth/tools.py
mediagoblin/plugins/oauth/views.py
mediagoblin/tests/test_http_callback.py
mediagoblin/tests/test_oauth2.py [moved from mediagoblin/tests/test_oauth.py with 95% similarity]

index 5dc71456cb48af2ee13471bda0113e4b4db4ffc9..bc3a7a7eb2d8edce73ac6409886a7805550ed63c 100644 (file)
@@ -23,7 +23,6 @@ add_route(
         "mediagoblin.federation.views:client_register"
         )
 
-
 add_route(
         "mediagoblin.federation",
         "/oauth/request_token",
@@ -42,8 +41,3 @@ add_route(
         "mediagoblin.federation.views:access_token"
         )
 
-add_route(
-        "mediagoblin.federation",
-        "/api/test",
-        "mediagoblin.federation.views:test"
-        )
index aae9d55a62f1e2deca1e0d7a2f5d33aa291dbe4b..94eb98863040d536400176262ce7ae038ba17e55 100644 (file)
@@ -346,7 +346,3 @@ def access_token(request):
     tokens = av.create_access_token(request, {})
     return form_response(tokens)
 
-@csrf_exempt
-@oauth_required 
-def test(request):
-    return json_response({"check":"OK"})
index 738ea25f07dde66d9e240ef66aca94e2a31b26b7..b7e74799883e1fabd1fd5942b6c724da5142790b 100644 (file)
@@ -21,7 +21,7 @@ from os.path import splitext
 from werkzeug.exceptions import BadRequest, Forbidden
 from werkzeug.wrappers import Response
 
-from mediagoblin.tools.json import json_response
+from mediagoblin.tools.response import json_response
 from mediagoblin.decorators import require_active_login
 from mediagoblin.meddleware.csrf import csrf_exempt
 from mediagoblin.media_types import sniff_media
index 5762379dea39c68f9fdddca1dd645424b23bb7b4..82c1f38093f3e004a2865530a6f7e330e41f37ed 100644 (file)
@@ -35,22 +35,22 @@ def setup_plugin():
 
     routes = [
         ('mediagoblin.plugins.oauth.authorize',
-            '/oauth/authorize',
+            '/oauth-2/authorize',
             'mediagoblin.plugins.oauth.views:authorize'),
         ('mediagoblin.plugins.oauth.authorize_client',
-            '/oauth/client/authorize',
+            '/oauth-2/client/authorize',
             'mediagoblin.plugins.oauth.views:authorize_client'),
         ('mediagoblin.plugins.oauth.access_token',
-            '/oauth/access_token',
+            '/oauth-2/access_token',
             'mediagoblin.plugins.oauth.views:access_token'),
         ('mediagoblin.plugins.oauth.list_connections',
-            '/oauth/client/connections',
+            '/oauth-2/client/connections',
             'mediagoblin.plugins.oauth.views:list_connections'),
         ('mediagoblin.plugins.oauth.register_client',
-            '/oauth/client/register',
+            '/oauth-2/client/register',
             'mediagoblin.plugins.oauth.views:register_client'),
         ('mediagoblin.plugins.oauth.list_clients',
-            '/oauth/client/list',
+            '/oauth-2/client/list',
             'mediagoblin.plugins.oauth.views:list_clients')]
 
     pluginapi.register_routes(routes)
index 1e0fc6ef7d5afbf53ef005a570293ecd5c0f74cd..af0a3305acf53cdc1a3b9fda718bb5cfb5a0a14f 100644 (file)
@@ -23,7 +23,7 @@ from datetime import datetime
 
 from functools import wraps
 
-from mediagoblin.tools.json import json_response
+from mediagoblin.tools.response import json_response
 
 
 def require_client_auth(controller):
index a5d66111ba6ead21a118263f5d17e7b9610629ff..de637d6b5027676251c9653ca92775fe7975278b 100644 (file)
@@ -21,8 +21,7 @@ from urllib import urlencode
 
 from werkzeug.exceptions import BadRequest
 
-from mediagoblin.tools.response import render_to_response, redirect
-from mediagoblin.tools.json import json_response
+from mediagoblin.tools.response import render_to_response, redirect, json_response
 from mediagoblin.decorators import require_active_login
 from mediagoblin.messages import add_message, SUCCESS
 from mediagoblin.tools.translate import pass_to_ugettext as _
index a0511af770ac977f5e88874378fcfd8679b42e06..64b7ee8f4cec8d389dcd5758a930b22db0413425 100644 (file)
@@ -23,7 +23,7 @@ from mediagoblin import mg_globals
 from mediagoblin.tools import processing
 from mediagoblin.tests.tools import fixture_add_user
 from mediagoblin.tests.test_submission import GOOD_PNG
-from mediagoblin.tests import test_oauth as oauth
+from mediagoblin.tests import test_oauth2 as oauth
 
 
 class TestHTTPCallback(object):
@@ -44,7 +44,7 @@ class TestHTTPCallback(object):
             'password': self.user_password})
 
     def get_access_token(self, client_id, client_secret, code):
-        response = self.test_app.get('/oauth/access_token', {
+        response = self.test_app.get('/oauth-2/access_token', {
                 'code': code,
                 'client_id': client_id,
                 'client_secret': client_secret})
similarity index 95%
rename from mediagoblin/tests/test_oauth.py
rename to mediagoblin/tests/test_oauth2.py
index ea3bd798d265d0990140e1b5d5edfe6ec8ecaf0e..86f9e8ccf942c5f918b789649923efa77c92951b 100644 (file)
@@ -51,7 +51,7 @@ class TestOAuth(object):
     def register_client(self, name, client_type, description=None,
                         redirect_uri=''):
         return self.test_app.post(
-                '/oauth/client/register', {
+                '/oauth-2/client/register', {
                     'name': name,
                     'description': description,
                     'type': client_type,
@@ -115,7 +115,7 @@ class TestOAuth(object):
         client_identifier = client.identifier
 
         redirect_uri = 'https://foo.example'
-        response = self.test_app.get('/oauth/authorize', {
+        response = self.test_app.get('/oauth-2/authorize', {
                 'client_id': client.identifier,
                 'scope': 'all',
                 'redirect_uri': redirect_uri})
@@ -129,7 +129,7 @@ class TestOAuth(object):
 
         # Short for client authorization post reponse
         capr = self.test_app.post(
-                '/oauth/client/authorize', {
+                '/oauth-2/client/authorize', {
                     'client_id': form.client_id.data,
                     'allow': 'Allow',
                     'next': form.next.data})
@@ -155,7 +155,7 @@ class TestOAuth(object):
         client = self.db.OAuthClient.query.filter(
                 self.db.OAuthClient.identifier == unicode(client_id)).first()
 
-        token_res = self.test_app.get('/oauth/access_token?client_id={0}&\
+        token_res = self.test_app.get('/oauth-2/access_token?client_id={0}&\
 code={1}&client_secret={2}'.format(client_id, code, client.secret))
 
         assert token_res.status_int == 200
@@ -183,7 +183,7 @@ code={1}&client_secret={2}'.format(client_id, code, client.secret))
         client = self.db.OAuthClient.query.filter(
                 self.db.OAuthClient.identifier == unicode(client_id)).first()
 
-        token_res = self.test_app.get('/oauth/access_token?\
+        token_res = self.test_app.get('/oauth-2/access_token?\
 code={0}&client_secret={1}'.format(code, client.secret))
 
         assert token_res.status_int == 200
@@ -204,7 +204,7 @@ code={0}&client_secret={1}'.format(code, client.secret))
         client = self.db.OAuthClient.query.filter(
             self.db.OAuthClient.identifier == client_id).first()
 
-        token_res = self.test_app.get('/oauth/access_token',
+        token_res = self.test_app.get('/oauth-2/access_token',
                      {'refresh_token': token_data['refresh_token'],
                       'client_id': client_id,
                       'client_secret': client.secret