@@ -53,12 +53,13 @@ func TestLogin(t *testing.T) {
53
53
"display form" : {
54
54
CSRF : & csrf.FakeCSRF {Token : "test" },
55
55
Auth : & testAuth {},
56
- Path : "/login" ,
56
+ Path : "/login?then=%2F " ,
57
57
58
58
ExpectStatusCode : 200 ,
59
59
ExpectContains : []string {
60
60
`action="/login"` ,
61
61
`name="csrf" value="test"` ,
62
+ `name="then" value="/"` ,
62
63
},
63
64
},
64
65
"display form with errors" : {
@@ -74,6 +75,21 @@ func TestLogin(t *testing.T) {
74
75
`danger` ,
75
76
},
76
77
},
78
+ "redirect when GET has no then param" : {
79
+ CSRF : & csrf.FakeCSRF {Token : "test" },
80
+ Auth : & testAuth {},
81
+ Path : "/login" ,
82
+
83
+ ExpectStatusCode : 302 ,
84
+ ExpectRedirect : "/" ,
85
+ },
86
+ "redirect when POST is missing then param" : {
87
+ CSRF : & csrf.FakeCSRF {Token : "test" },
88
+ Auth : & testAuth {},
89
+ Path : "/login" ,
90
+ PostValues : url.Values {"csrf" : []string {"test" }},
91
+ ExpectRedirect : "/" ,
92
+ },
77
93
"redirect when POST fails CSRF" : {
78
94
CSRF : & csrf.FakeCSRF {Token : "test" },
79
95
Auth : & testAuth {},
@@ -94,8 +110,9 @@ func TestLogin(t *testing.T) {
94
110
Path : "/login" ,
95
111
PostValues : url.Values {
96
112
"csrf" : []string {"test" },
113
+ "then" : []string {"anotherurl" },
97
114
},
98
- ExpectRedirect : "/login?reason=user_required" ,
115
+ ExpectRedirect : "/login?reason=user_required&then=anotherurl " ,
99
116
},
100
117
"redirect when not authenticated" : {
101
118
CSRF : & csrf.FakeCSRF {Token : "test" },
@@ -104,8 +121,9 @@ func TestLogin(t *testing.T) {
104
121
PostValues : url.Values {
105
122
"csrf" : []string {"test" },
106
123
"username" : []string {"user" },
124
+ "then" : []string {"anotherurl" },
107
125
},
108
- ExpectRedirect : "/login?reason=access_denied" ,
126
+ ExpectRedirect : "/login?reason=access_denied&then=anotherurl " ,
109
127
},
110
128
"redirect on auth error" : {
111
129
CSRF : & csrf.FakeCSRF {Token : "test" },
@@ -114,8 +132,9 @@ func TestLogin(t *testing.T) {
114
132
PostValues : url.Values {
115
133
"csrf" : []string {"test" },
116
134
"username" : []string {"user" },
135
+ "then" : []string {"anotherurl" },
117
136
},
118
- ExpectRedirect : "/login?reason=authentication_error" ,
137
+ ExpectRedirect : "/login?reason=authentication_error&then=anotherurl " ,
119
138
},
120
139
"redirect on lookup error" : {
121
140
CSRF : & csrf.FakeCSRF {Token : "test" },
@@ -124,8 +143,9 @@ func TestLogin(t *testing.T) {
124
143
PostValues : url.Values {
125
144
"csrf" : []string {"test" },
126
145
"username" : []string {"user" },
146
+ "then" : []string {"anotherurl" },
127
147
},
128
- ExpectRedirect : "/login?reason=mapping_lookup_error" ,
148
+ ExpectRedirect : "/login?reason=mapping_lookup_error&then=anotherurl " ,
129
149
},
130
150
"redirect on claim error" : {
131
151
CSRF : & csrf.FakeCSRF {Token : "test" },
@@ -134,8 +154,9 @@ func TestLogin(t *testing.T) {
134
154
PostValues : url.Values {
135
155
"csrf" : []string {"test" },
136
156
"username" : []string {"user" },
157
+ "then" : []string {"anotherurl" },
137
158
},
138
- ExpectRedirect : "/login?reason=mapping_claim_error" ,
159
+ ExpectRedirect : "/login?reason=mapping_claim_error&then=anotherurl " ,
139
160
},
140
161
"redirect preserving then param" : {
141
162
CSRF : & csrf.FakeCSRF {Token : "test" },
0 commit comments