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

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 5234
Proposed branch: lp:~blake-rouse/maas/fix-1611342
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 59 lines (+12/-3)
3 files modified
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
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+302436@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
Andres Rodriguez (andreserl) wrote :

lgtm!

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.4 MiB)

The attempt to merge lp:~blake-rouse/maas/fix-1611342 into lp:maas failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
Hit:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB]
Hit:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease
Fetched 190 kB in 0s (452 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
archdetect-deb is already the newest version (1.117ubuntu2).
authbind is already the newest version (2.1.1+nmu1).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
freeipmi-tools is already the newest version (1.4.11-1ubuntu1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
pytho...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 15:40:34 +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 15:40:34 +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 15:40:34 +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" />