Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f2d187

Browse filesBrowse files
author
anonx
committed
Modified persona tests to reflect the latest changes
1 parent 8c2bc6f commit 7f2d187
Copy full SHA for 7f2d187

File tree

Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed

‎samples/persona/tests/apptest.go

Copy file name to clipboardExpand all lines: samples/persona/tests/apptest.go
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package tests
22

33
import (
44
"encoding/json"
5-
"net/http"
65
"net/url"
76

87
"github.com/revel/revel"
@@ -19,7 +18,7 @@ type PersonaTestUser struct {
1918
Pass string `json:"pass"`
2019
}
2120

22-
func (t AppTest) TestThatLoginPageWorks() {
21+
func (t *AppTest) TestThatLoginPageWorks() {
2322
// Make sure empty assertion will cause an error.
2423
t.PostForm("/login", url.Values{
2524
"assertion": []string{""},
@@ -47,7 +46,7 @@ func (t AppTest) TestThatLoginPageWorks() {
4746
t.AssertContains(user.Email)
4847
}
4948

50-
func (t AppTest) TestThatLogoutPageWorks() {
49+
func (t *AppTest) TestThatLogoutPageWorks() {
5150
// Authenticating a user.
5251
user := t.EmailWithAssertion("http://" + revel.Config.StringDefault("http.host", "localhost"))
5352
t.PostForm("/login", url.Values{
@@ -69,22 +68,23 @@ func (t AppTest) TestThatLogoutPageWorks() {
6968
}
7069

7170
// EmailWithAssertion uses personatestuser.org service for getting testing parameters.
72-
// Audience is expected to begin with protocol, for example: "http://".
73-
func (t AppTest) EmailWithAssertion(audience string) *PersonaTestUser {
71+
// The testing service expects audience to begin with protocol, for example: "http://".
72+
func (t *AppTest) EmailWithAssertion(audience string) *PersonaTestUser {
7473
// Trying to get data from testing server.
75-
uri := "/email_with_assertion/" + url.QueryEscape(audience)
76-
req, err := http.NewRequest("GET", "http://personatestuser.org"+uri, nil)
77-
t.Assert(err == nil)
78-
req.URL.Opaque = uri // Use unescaped version of URI for request.
79-
t.MakeRequest(req)
74+
u := "http://personatestuser.org"
75+
urn := "/email_with_assertion/" + url.QueryEscape(audience)
76+
77+
req := t.GetCustom(u + urn)
78+
req.URL.Opaque = urn // Use unescaped version of URN for the request.
79+
req.Send()
8080

8181
// Check whether response status is OK.
8282
revel.TRACE.Printf("PERSONA TESTING: Response of testing server is %q", t.ResponseBody)
8383
t.AssertOk()
8484

8585
// Parsing the response from server.
8686
var user PersonaTestUser
87-
err = json.Unmarshal(t.ResponseBody, &user)
87+
err := json.Unmarshal(t.ResponseBody, &user)
8888
t.Assert(err == nil)
8989

9090
return &user

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.