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
=== modified file 'usso.go'
--- usso.go 2013-02-22 11:55:13 +0000
+++ usso.go 2013-02-27 15:17:29 +0000
@@ -17,7 +17,7 @@
1717
18// tokenURL returns the URL where the Ubuntu SSO tokens can be requested.18// tokenURL returns the URL where the Ubuntu SSO tokens can be requested.
19func (server UbuntuSSOServer) tokenURL() string {19func (server UbuntuSSOServer) tokenURL() string {
20 return server.baseUrl + "/api/v2/tokens"20 return server.baseUrl + "/api/v2/tokens/oauth"
21}21}
2222
23// AccountURL returns the URL where the Ubuntu SSO account information can be 23// AccountURL returns the URL where the Ubuntu SSO account information can be
@@ -58,7 +58,7 @@
58 if response.StatusCode == 404 {58 if response.StatusCode == 404 {
59 return nil, errors.New("Wrong credentials.")59 return nil, errors.New("Wrong credentials.")
60 }60 }
61 if response.StatusCode != 200 {61 if response.StatusCode != 200 && response.StatusCode != 201 {
62 return nil, fmt.Errorf("SSO Error: %s\n", response.Status)62 return nil, fmt.Errorf("SSO Error: %s\n", response.Status)
63 }63 }
64 body, err := ioutil.ReadAll(response.Body)64 body, err := ioutil.ReadAll(response.Body)
6565
=== modified file 'usso_test.go'
--- usso_test.go 2013-02-22 12:47:56 +0000
+++ usso_test.go 2013-02-27 15:17:29 +0000
@@ -35,13 +35,13 @@
35// TestProductionUbuntuSSOServerURLs tests the URLs of the production server.35// TestProductionUbuntuSSOServerURLs tests the URLs of the production server.
36func (suite *USSOTestSuite) TestProductionUbuntuSSOServerURLs(c *C) {36func (suite *USSOTestSuite) TestProductionUbuntuSSOServerURLs(c *C) {
37 tokenURL := ProductionUbuntuSSOServer.tokenURL()37 tokenURL := ProductionUbuntuSSOServer.tokenURL()
38 c.Assert(tokenURL, Equals, "https://login.ubuntu.com/api/v2/tokens")38 c.Assert(tokenURL, Equals, "https://login.ubuntu.com/api/v2/tokens/oauth")
39}39}
4040
41// TestStagingUbuntuSSOServerURLs tests the URLs of the staging server.41// TestStagingUbuntuSSOServerURLs tests the URLs of the staging server.
42func (suite *USSOTestSuite) TestStagingUbuntuSSOServerURLs(c *C) {42func (suite *USSOTestSuite) TestStagingUbuntuSSOServerURLs(c *C) {
43 tokenURL := StagingUbuntuSSOServer.tokenURL()43 tokenURL := StagingUbuntuSSOServer.tokenURL()
44 c.Assert(tokenURL, Equals, "https://login.staging.ubuntu.com/api/v2/tokens")44 c.Assert(tokenURL, Equals, "https://login.staging.ubuntu.com/api/v2/tokens/oauth")
45}45}
4646
47// newSingleServingServer create a single-serving test http server which will47// newSingleServingServer create a single-serving test http server which will
@@ -87,7 +87,7 @@
87 if err != nil {87 if err != nil {
88 panic(err)88 panic(err)
89 }89 }
90 server := newSingleServingServer("/api/v2/tokens",90 server := newSingleServingServer("/api/v2/tokens/oauth",
91 string(jsonServerResponseData), 200)91 string(jsonServerResponseData), 200)
92 var testSSOServer = &UbuntuSSOServer{server.URL}92 var testSSOServer = &UbuntuSSOServer{server.URL}
93 defer server.Close()93 defer server.Close()
@@ -114,7 +114,7 @@
114114
115// GetToken should return empty credentials and an error, if wrong account is provided.115// GetToken should return empty credentials and an error, if wrong account is provided.
116func (suite *USSOTestSuite) TestGetTokenFails(c *C) {116func (suite *USSOTestSuite) TestGetTokenFails(c *C) {
117 server := newSingleServingServer("/api/v2/tokens", "{}", 200)117 server := newSingleServingServer("/api/v2/tokens/oauth", "{}", 200)
118 var testSSOServer = &UbuntuSSOServer{server.URL}118 var testSSOServer = &UbuntuSSOServer{server.URL}
119 defer server.Close()119 defer server.Close()
120 ssodata, err := testSSOServer.GetToken(email, "WRONG", tokenName)120 ssodata, err := testSSOServer.GetToken(email, "WRONG", tokenName)

Subscribers

People subscribed via source and target branches

to all changes: