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
=== modified file 'docs/changelog.rst'
--- docs/changelog.rst 2016-08-09 17:19:45 +0000
+++ docs/changelog.rst 2016-08-09 19:34:17 +0000
@@ -15,6 +15,8 @@
1515
16LP: #1610397 When juju adds containers to MAAS, ensure they inherit the parent machine domain name, if none is passed by Juju.16LP: #1610397 When juju adds containers to MAAS, ensure they inherit the parent machine domain name, if none is passed by Juju.
1717
18LP: #1611342 UI error while generating a MAAS key (token).
19
1820
192.0.0 (rc3)212.0.0 (rc3)
20===========22===========
2123
=== modified file 'src/maasserver/api/account.py'
--- src/maasserver/api/account.py 2016-03-28 13:54:47 +0000
+++ src/maasserver/api/account.py 2016-08-09 19:34:17 +0000
@@ -7,7 +7,10 @@
7 'AccountHandler',7 'AccountHandler',
8 ]8 ]
99
10import http.client
11import json
1012
13from django.http import HttpResponse
11from maasserver.api.support import (14from maasserver.api.support import (
12 operation,15 operation,
13 OperationsHandler,16 OperationsHandler,
@@ -34,10 +37,14 @@
34 """37 """
35 profile = request.user.userprofile38 profile = request.user.userprofile
36 consumer, token = profile.create_authorisation_token()39 consumer, token = profile.create_authorisation_token()
37 return {40 auth_info = {
38 'token_key': token.key, 'token_secret': token.secret,41 'token_key': token.key, 'token_secret': token.secret,
39 'consumer_key': consumer.key,42 'consumer_key': consumer.key,
40 }43 }
44 return HttpResponse(
45 json.dumps(auth_info),
46 content_type='application/json; charset=utf-8',
47 status=int(http.client.OK))
4148
42 @operation(idempotent=False)49 @operation(idempotent=False)
43 def delete_authorisation_token(self, request):50 def delete_authorisation_token(self, request):
4451
=== modified file 'src/maasserver/api/tests/test_api.py'
--- src/maasserver/api/tests/test_api.py 2016-06-14 18:49:19 +0000
+++ src/maasserver/api/tests/test_api.py 2016-08-09 19:34:17 +0000
@@ -177,8 +177,10 @@
177 # with the consumer_key, the token_key and the token_secret in it.177 # with the consumer_key, the token_key and the token_secret in it.
178 response = self.client.post(178 response = self.client.post(
179 reverse('account_handler'), {'op': 'create_authorisation_token'})179 reverse('account_handler'), {'op': 'create_authorisation_token'})
180 self.assertEqual(http.client.OK, response.status_code)
181 self.assertEqual(
182 'application/json; charset=utf-8', response["content-type"])
180 parsed_result = json_load_bytes(response.content)183 parsed_result = json_load_bytes(response.content)
181
182 self.assertEqual(184 self.assertEqual(
183 ['consumer_key', 'token_key', 'token_secret'],185 ['consumer_key', 'token_key', 'token_secret'],
184 sorted(parsed_result))186 sorted(parsed_result))
185187
=== modified file 'src/maasserver/templates/maasserver/prefs.html'
--- src/maasserver/templates/maasserver/prefs.html 2015-03-30 09:35:45 +0000
+++ src/maasserver/templates/maasserver/prefs.html 2016-08-09 19:34:17 +0000
@@ -27,7 +27,7 @@
27 <ul class="no-bullets">27 <ul class="no-bullets">
28 {% for token in user.userprofile.get_authorisation_tokens %}28 {% for token in user.userprofile.get_authorisation_tokens %}
29 <li class="bundle">29 <li class="bundle">
30 <a href="#" class="delete-link icon right">30 <a href="#" class="u-margin--top-tiny delete-link icon right">
31 <img title="Delete MAAS key" class="left" src="{{ STATIC_URL }}img/delete.png" />31 <img title="Delete MAAS key" class="left" src="{{ STATIC_URL }}img/delete.png" />
32 </a>32 </a>
33 <input type="text" value="{{ token.consumer.key }}:{{ token.key }}:{{ token.secret }}" id="{{ token.key }}" class="disabled" />33 <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: