@@ -2,7 +2,6 @@ package tests
2
2
3
3
import (
4
4
"encoding/json"
5
- "net/http"
6
5
"net/url"
7
6
8
7
"github.com/revel/revel"
@@ -19,7 +18,7 @@ type PersonaTestUser struct {
19
18
Pass string `json:"pass"`
20
19
}
21
20
22
- func (t AppTest ) TestThatLoginPageWorks () {
21
+ func (t * AppTest ) TestThatLoginPageWorks () {
23
22
// Make sure empty assertion will cause an error.
24
23
t .PostForm ("/login" , url.Values {
25
24
"assertion" : []string {"" },
@@ -47,7 +46,7 @@ func (t AppTest) TestThatLoginPageWorks() {
47
46
t .AssertContains (user .Email )
48
47
}
49
48
50
- func (t AppTest ) TestThatLogoutPageWorks () {
49
+ func (t * AppTest ) TestThatLogoutPageWorks () {
51
50
// Authenticating a user.
52
51
user := t .EmailWithAssertion ("http://" + revel .Config .StringDefault ("http.host" , "localhost" ))
53
52
t .PostForm ("/login" , url.Values {
@@ -69,22 +68,23 @@ func (t AppTest) TestThatLogoutPageWorks() {
69
68
}
70
69
71
70
// 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 {
74
73
// 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 ()
80
80
81
81
// Check whether response status is OK.
82
82
revel .TRACE .Printf ("PERSONA TESTING: Response of testing server is %q" , t .ResponseBody )
83
83
t .AssertOk ()
84
84
85
85
// Parsing the response from server.
86
86
var user PersonaTestUser
87
- err = json .Unmarshal (t .ResponseBody , & user )
87
+ err : = json .Unmarshal (t .ResponseBody , & user )
88
88
t .Assert (err == nil )
89
89
90
90
return & user
0 commit comments