Merge lp:~cjwatson/launchpad/snap-upload-content-type into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18077
Proposed branch: lp:~cjwatson/launchpad/snap-upload-content-type
Merge into: lp:launchpad
Diff against target: 48 lines (+7/-8)
2 files modified
lib/lp/snappy/model/snapstoreclient.py (+1/-1)
lib/lp/snappy/tests/test_snapstoreclient.py (+6/-7)
To merge this branch: bzr merge lp:~cjwatson/launchpad/snap-upload-content-type
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini (community) Approve
Launchpad code reviewers Pending
Review via email: mp+295983@code.launchpad.net

Commit message

Use Content-Type: application/json when POSTing to snap-upload endpoint.

Description of the change

Use Content-Type: application/json when POSTing to snap-upload endpoint. SCA now requires this.

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/snappy/model/snapstoreclient.py'
--- lib/lp/snappy/model/snapstoreclient.py 2016-05-24 09:36:45 +0000
+++ lib/lp/snappy/model/snapstoreclient.py 2016-05-27 20:29:51 +0000
@@ -157,7 +157,7 @@
157 try:157 try:
158 assert snap.store_secrets is not None158 assert snap.store_secrets is not None
159 urlfetch(159 urlfetch(
160 upload_url, method="POST", data=data,160 upload_url, method="POST", json=data,
161 auth=MacaroonAuth(161 auth=MacaroonAuth(
162 snap.store_secrets["root"],162 snap.store_secrets["root"],
163 snap.store_secrets["discharge"]))163 snap.store_secrets["discharge"]))
164164
=== modified file 'lib/lp/snappy/tests/test_snapstoreclient.py'
--- lib/lp/snappy/tests/test_snapstoreclient.py 2016-05-24 09:36:45 +0000
+++ lib/lp/snappy/tests/test_snapstoreclient.py 2016-05-27 20:29:51 +0000
@@ -26,6 +26,7 @@
26from requests.utils import parse_dict_header26from requests.utils import parse_dict_header
27from testtools.matchers import (27from testtools.matchers import (
28 Contains,28 Contains,
29 ContainsDict,
29 Equals,30 Equals,
30 KeysEqual,31 KeysEqual,
31 Matcher,32 Matcher,
@@ -168,6 +169,7 @@
168 self.assertThat(self.request, RequestMatches(169 self.assertThat(self.request, RequestMatches(
169 url=Equals("http://sca.example/dev/api/acl/"),170 url=Equals("http://sca.example/dev/api/acl/"),
170 method=Equals("POST"),171 method=Equals("POST"),
172 headers=ContainsDict({"Content-Type": Equals("application/json")}),
171 json_data={173 json_data={
172 "packages": [{"name": "test-snap", "series": "rolling"}],174 "packages": [{"name": "test-snap", "series": "rolling"}],
173 "permissions": ["package_upload"],175 "permissions": ["package_upload"],
@@ -255,11 +257,8 @@
255 self.assertThat(self.snap_upload_request, RequestMatches(257 self.assertThat(self.snap_upload_request, RequestMatches(
256 url=Equals("http://sca.example/dev/api/snap-upload/"),258 url=Equals("http://sca.example/dev/api/snap-upload/"),
257 method=Equals("POST"),259 method=Equals("POST"),
260 headers=ContainsDict({"Content-Type": Equals("application/json")}),
258 auth=("Macaroon", MacaroonsVerify(root_key)),261 auth=("Macaroon", MacaroonsVerify(root_key)),
259 form_data={262 json_data={
260 "name": MatchesStructure.byEquality(263 "name": "test-snap", "updown_id": 1, "series": "rolling",
261 name="name", value="test-snap"),264 }))
262 "updown_id": MatchesStructure.byEquality(
263 name="updown_id", value="1"),
264 "series": MatchesStructure.byEquality(
265 name="series", value="rolling")}))