Merge lp:~vds/usso/fix_and_point_and_check_for_201_too into lp:usso

Proposed by Vincenzo Di Somma
Status: Merged
Approved by: Graham Binns
Approved revision: 29
Merged at revision: 29
Proposed branch: lp:~vds/usso/fix_and_point_and_check_for_201_too
Merge into: lp:usso
Diff against target: 59 lines (+6/-6)
2 files modified
usso.go (+2/-2)
usso_test.go (+4/-4)
To merge this branch: bzr merge lp:~vds/usso/fix_and_point_and_check_for_201_too
Reviewer Review Type Date Requested Status
Domas Monkus (community) Approve
Graham Binns (community) Approve
Andrew W. Deane (community) Approve
Review via email: mp+150823@code.launchpad.net

Commit message

The tokens end point is changed, plus we also need to handle status code 201 as a success.

Description of the change

The tokens end point is changed, plus we also need to handle status code 201 as a success.

To post a comment you must log in.
Revision history for this message
Andrew W. Deane (andrew-w-deane) :
review: Approve
Revision history for this message
Graham Binns (gmb) :
review: Approve
Revision history for this message
Domas Monkus (tasdomas) wrote :

Perhaps it would be a good idea to have constants for the urls (they seem to be repeating), but that's just a maybe-someday.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'usso.go'
2--- usso.go 2013-02-22 11:55:13 +0000
3+++ usso.go 2013-02-27 15:17:29 +0000
4@@ -17,7 +17,7 @@
5
6 // tokenURL returns the URL where the Ubuntu SSO tokens can be requested.
7 func (server UbuntuSSOServer) tokenURL() string {
8- return server.baseUrl + "/api/v2/tokens"
9+ return server.baseUrl + "/api/v2/tokens/oauth"
10 }
11
12 // AccountURL returns the URL where the Ubuntu SSO account information can be
13@@ -58,7 +58,7 @@
14 if response.StatusCode == 404 {
15 return nil, errors.New("Wrong credentials.")
16 }
17- if response.StatusCode != 200 {
18+ if response.StatusCode != 200 && response.StatusCode != 201 {
19 return nil, fmt.Errorf("SSO Error: %s\n", response.Status)
20 }
21 body, err := ioutil.ReadAll(response.Body)
22
23=== modified file 'usso_test.go'
24--- usso_test.go 2013-02-22 12:47:56 +0000
25+++ usso_test.go 2013-02-27 15:17:29 +0000
26@@ -35,13 +35,13 @@
27 // TestProductionUbuntuSSOServerURLs tests the URLs of the production server.
28 func (suite *USSOTestSuite) TestProductionUbuntuSSOServerURLs(c *C) {
29 tokenURL := ProductionUbuntuSSOServer.tokenURL()
30- c.Assert(tokenURL, Equals, "https://login.ubuntu.com/api/v2/tokens")
31+ c.Assert(tokenURL, Equals, "https://login.ubuntu.com/api/v2/tokens/oauth")
32 }
33
34 // TestStagingUbuntuSSOServerURLs tests the URLs of the staging server.
35 func (suite *USSOTestSuite) TestStagingUbuntuSSOServerURLs(c *C) {
36 tokenURL := StagingUbuntuSSOServer.tokenURL()
37- c.Assert(tokenURL, Equals, "https://login.staging.ubuntu.com/api/v2/tokens")
38+ c.Assert(tokenURL, Equals, "https://login.staging.ubuntu.com/api/v2/tokens/oauth")
39 }
40
41 // newSingleServingServer create a single-serving test http server which will
42@@ -87,7 +87,7 @@
43 if err != nil {
44 panic(err)
45 }
46- server := newSingleServingServer("/api/v2/tokens",
47+ server := newSingleServingServer("/api/v2/tokens/oauth",
48 string(jsonServerResponseData), 200)
49 var testSSOServer = &UbuntuSSOServer{server.URL}
50 defer server.Close()
51@@ -114,7 +114,7 @@
52
53 // GetToken should return empty credentials and an error, if wrong account is provided.
54 func (suite *USSOTestSuite) TestGetTokenFails(c *C) {
55- server := newSingleServingServer("/api/v2/tokens", "{}", 200)
56+ server := newSingleServingServer("/api/v2/tokens/oauth", "{}", 200)
57 var testSSOServer = &UbuntuSSOServer{server.URL}
58 defer server.Close()
59 ssodata, err := testSSOServer.GetToken(email, "WRONG", tokenName)

Subscribers

People subscribed via source and target branches

to all changes: