Merge lp:~blake-rouse/maas/fix-1611342-2.0 into lp:maas/2.0

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 5186
Proposed branch: lp:~blake-rouse/maas/fix-1611342-2.0
Merge into: lp:maas/2.0
Diff against target: 72 lines (+14/-3)
4 files modified
docs/changelog.rst (+2/-0)
src/maasserver/api/account.py (+8/-1)
src/maasserver/api/tests/test_api.py (+3/-1)
src/maasserver/templates/maasserver/prefs.html (+1/-1)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1611342-2.0
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+302461@code.launchpad.net

Commit message

Fix create_authorisation_token operation to return with content-type so javascript can decode the response.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Self-approving backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/changelog.rst'
2--- docs/changelog.rst 2016-08-09 17:19:45 +0000
3+++ docs/changelog.rst 2016-08-09 19:34:17 +0000
4@@ -15,6 +15,8 @@
5
6 LP: #1610397 When juju adds containers to MAAS, ensure they inherit the parent machine domain name, if none is passed by Juju.
7
8+LP: #1611342 UI error while generating a MAAS key (token).
9+
10
11 2.0.0 (rc3)
12 ===========
13
14=== modified file 'src/maasserver/api/account.py'
15--- src/maasserver/api/account.py 2016-03-28 13:54:47 +0000
16+++ src/maasserver/api/account.py 2016-08-09 19:34:17 +0000
17@@ -7,7 +7,10 @@
18 'AccountHandler',
19 ]
20
21+import http.client
22+import json
23
24+from django.http import HttpResponse
25 from maasserver.api.support import (
26 operation,
27 OperationsHandler,
28@@ -34,10 +37,14 @@
29 """
30 profile = request.user.userprofile
31 consumer, token = profile.create_authorisation_token()
32- return {
33+ auth_info = {
34 'token_key': token.key, 'token_secret': token.secret,
35 'consumer_key': consumer.key,
36 }
37+ return HttpResponse(
38+ json.dumps(auth_info),
39+ content_type='application/json; charset=utf-8',
40+ status=int(http.client.OK))
41
42 @operation(idempotent=False)
43 def delete_authorisation_token(self, request):
44
45=== modified file 'src/maasserver/api/tests/test_api.py'
46--- src/maasserver/api/tests/test_api.py 2016-06-14 18:49:19 +0000
47+++ src/maasserver/api/tests/test_api.py 2016-08-09 19:34:17 +0000
48@@ -177,8 +177,10 @@
49 # with the consumer_key, the token_key and the token_secret in it.
50 response = self.client.post(
51 reverse('account_handler'), {'op': 'create_authorisation_token'})
52+ self.assertEqual(http.client.OK, response.status_code)
53+ self.assertEqual(
54+ 'application/json; charset=utf-8', response["content-type"])
55 parsed_result = json_load_bytes(response.content)
56-
57 self.assertEqual(
58 ['consumer_key', 'token_key', 'token_secret'],
59 sorted(parsed_result))
60
61=== modified file 'src/maasserver/templates/maasserver/prefs.html'
62--- src/maasserver/templates/maasserver/prefs.html 2015-03-30 09:35:45 +0000
63+++ src/maasserver/templates/maasserver/prefs.html 2016-08-09 19:34:17 +0000
64@@ -27,7 +27,7 @@
65 <ul class="no-bullets">
66 {% for token in user.userprofile.get_authorisation_tokens %}
67 <li class="bundle">
68- <a href="#" class="delete-link icon right">
69+ <a href="#" class="u-margin--top-tiny delete-link icon right">
70 <img title="Delete MAAS key" class="left" src="{{ STATIC_URL }}img/delete.png" />
71 </a>
72 <input type="text" value="{{ token.consumer.key }}:{{ token.key }}:{{ token.secret }}" id="{{ token.key }}" class="disabled" />

Subscribers

People subscribed via source and target branches

to all changes: