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

Fix IARC v2 PushCert API #3505

Merged
merged 1 commit into from Feb 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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