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

Commit

Permalink
Merge pull request #3505 from diox/iarc-v2-fix-uuid-pushcert
Browse files Browse the repository at this point in the history
Fix IARC v2 PushCert API
  • Loading branch information
diox committed Feb 4, 2016
2 parents df3776c + a9c7587 commit 7f26705
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
18 changes: 16 additions & 2 deletions mkt/developers/tests/test_views_api.py
Expand Up @@ -339,6 +339,13 @@ def test_post_no_store_request_id(self):
eq_(res.data, {'detail': 'Need a StoreRequestID',
'StatusCode': 'InvalidRequest'})

def test_post_store_request_id_is_not_an_uuid(self):
res = self.anon.post(self.url, data=json.dumps(
{'StoreRequestID': 'garbage'}))
eq_(res.status_code, 400)
eq_(res.data, {'detail': 'StoreRequestID is not a valid UUID',
'StatusCode': 'InvalidRequest'})

def test_post_store_request_id_not_found(self):
res = self.anon.post(self.url, data=json.dumps(
{'StoreRequestID': unicode(uuid.uuid4())}))
Expand All @@ -354,10 +361,17 @@ def test_post_error(self):
{'RatingList': 'This field is required.',
'StatusCode': 'InvalidRequest'})

def test_post_success(self):
def test_post_success_uuid_without_separators(self):
request = IARCRequest.objects.create(app=self.app)
self._test_post_success(unicode(request.uuid))

def test_post_success_uuid_with_separators(self):
request = IARCRequest.objects.create(app=self.app)
self._test_post_success(unicode(uuid.UUID(request.uuid)))

def _test_post_success(self, store_request_uuid):
data = {
'StoreRequestID': unicode(request.uuid),
'StoreRequestID': store_request_uuid,
'CertID': unicode(uuid.uuid4()),
'RatingList': [
{
Expand Down
5 changes: 4 additions & 1 deletion mkt/developers/views.py
Expand Up @@ -1205,9 +1205,12 @@ class ContentRatingsPingbackV2(CORSMixin, UpdateModelMixin, GenericAPIView):
def get_object(self, queryset=None):
request = self.request
try:
self.kwargs[self.lookup_field] = request.data['StoreRequestID']
self.kwargs[self.lookup_field] = uuid.UUID(
request.data['StoreRequestID']).get_hex()
except KeyError:
raise ParseError('Need a StoreRequestID')
except ValueError:
raise ParseError('StoreRequestID is not a valid UUID')
self.object = super(ContentRatingsPingbackV2, self).get_object().app
return self.object

Expand Down

0 comments on commit 7f26705

Please sign in to comment.