Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #59 from e-ducation/xavierchan/no-url-validation
Browse files Browse the repository at this point in the history
Disable url validation in client creation
  • Loading branch information
Julia Eskew committed Aug 2, 2019
2 parents 33cff73 + a056bdc commit 4ddf8e3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 29 deletions.
2 changes: 1 addition & 1 deletion edx_oauth2_provider/__init__.py
Expand Up @@ -4,4 +4,4 @@
"""
from __future__ import unicode_literals

__version__ = '1.2.3'
__version__ = '1.3.0'
17 changes: 0 additions & 17 deletions edx_oauth2_provider/management/commands/create_oauth2_client.py
Expand Up @@ -6,9 +6,7 @@
import json

from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.core.management.base import BaseCommand, CommandError
from django.core.validators import URLValidator
from provider.constants import CONFIDENTIAL, PUBLIC
from provider.oauth2.models import Client

Expand Down Expand Up @@ -117,13 +115,6 @@ def _clean_required_args(self, url, redirect_uri, client_type):
Raises:
CommandError, if the URLs provided are invalid, or if the client type provided is invalid.
"""
# Validate URLs
for url_to_validate in (url, redirect_uri):
try:
URLValidator()(url_to_validate)
except ValidationError:
raise CommandError("URLs provided are invalid. Please provide valid application and redirect URLs.")

# Validate and map client type to the appropriate django-oauth2-provider constant
client_type = client_type.lower()
client_type = {
Expand Down Expand Up @@ -167,11 +158,3 @@ def _parse_options(self, options):
client_name = self.fields.pop('client_name', None)
if client_name is not None:
self.fields['name'] = client_name

logout_uri = self.fields.get('logout_uri')

if logout_uri:
try:
URLValidator()(logout_uri)
except ValidationError:
raise CommandError("The logout_uri is invalid.")
11 changes: 0 additions & 11 deletions edx_oauth2_provider/tests/test_create_oauth2_client.py
Expand Up @@ -111,17 +111,6 @@ def test_argument_cardinality(self, args, err_msg):
self._call_command(args, {})
self.assertIn(err_msg, str(exc.exception))

@ddt.data(
('invalid', REDIRECT_URI, CLIENT_TYPES[0]),
(URL, 'invalid', CLIENT_TYPES[0]),
)
def test_url_validation(self, args):
"""Verify that the command fails when the provided URLs are invalid."""
with self.assertRaises(CommandError) as exc:
self._call_command(args)

self.assertIn('URLs provided are invalid.', str(exc.exception))

def test_client_type_validation(self):
"""Verify that the command fails when the provided client type is invalid."""
with self.assertRaises(CommandError) as exc:
Expand Down

0 comments on commit 4ddf8e3

Please sign in to comment.