Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
go-sso
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
id
go-sso
Commits
c31754c5
Commit
c31754c5
authored
Nov 02, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a logout test
parent
5e99c3de
Pipeline
#1459
passed with stages
in 1 minute and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
server/http_test.go
server/http_test.go
+63
-0
No files found.
server/http_test.go
View file @
c31754c5
...
...
@@ -195,6 +195,69 @@ func TestHTTP_Login(t *testing.T) {
doPostForm
(
t
,
httpSrv
,
c
,
"/login"
,
v
,
checkRedirectToTargetService
)
}
func
TestHTTP_LoginOnSecondAttempt
(
t
*
testing
.
T
)
{
tmpdir
,
httpSrv
:=
startTestHTTPServer
(
t
)
defer
os
.
RemoveAll
(
tmpdir
)
defer
httpSrv
.
Close
()
c
:=
newTestHTTPClient
()
// Simulate an authorization request from a service, expect to
// see the login page.
v
:=
make
(
url
.
Values
)
v
.
Set
(
"s"
,
"service.example.com/"
)
v
.
Set
(
"d"
,
"https://service.example.com/admin/"
)
v
.
Set
(
"n"
,
"averysecretnonce"
)
doGet
(
t
,
httpSrv
,
c
,
"/?"
+
v
.
Encode
(),
checkStatusOk
,
checkLoginPasswordPage
)
// Attempt to login with wrong credentials.
v
=
make
(
url
.
Values
)
v
.
Set
(
"username"
,
"testuser"
)
v
.
Set
(
"password"
,
"badpassword"
)
doPostForm
(
t
,
httpSrv
,
c
,
"/login"
,
v
,
checkStatusOk
,
checkLoginPasswordPage
)
// Attempt to login by submitting the form. We expect the
// result to be a 302 redirect to the target service.
v
=
make
(
url
.
Values
)
v
.
Set
(
"username"
,
"testuser"
)
v
.
Set
(
"password"
,
"password"
)
doPostForm
(
t
,
httpSrv
,
c
,
"/login"
,
v
,
checkRedirectToTargetService
)
}
func
TestHTTP_LoginAndLogout
(
t
*
testing
.
T
)
{
tmpdir
,
httpSrv
:=
startTestHTTPServer
(
t
)
defer
os
.
RemoveAll
(
tmpdir
)
defer
httpSrv
.
Close
()
c
:=
newTestHTTPClient
()
// Simulate an authorization request from a service, expect to
// see the login page.
v
:=
make
(
url
.
Values
)
v
.
Set
(
"s"
,
"service.example.com/"
)
v
.
Set
(
"d"
,
"https://service.example.com/admin/"
)
v
.
Set
(
"n"
,
"averysecretnonce"
)
doGet
(
t
,
httpSrv
,
c
,
"/?"
+
v
.
Encode
(),
checkStatusOk
,
checkLoginPasswordPage
)
// Attempt to login by submitting the form. We expect the
// result to be a 302 redirect to the target service.
v
=
make
(
url
.
Values
)
v
.
Set
(
"username"
,
"testuser"
)
v
.
Set
(
"password"
,
"password"
)
doPostForm
(
t
,
httpSrv
,
c
,
"/login"
,
v
,
checkRedirectToTargetService
)
// Make a logout request.
doGet
(
t
,
httpSrv
,
c
,
"/logout"
,
checkStatusOk
)
doPostForm
(
t
,
httpSrv
,
c
,
"/logout"
,
nil
,
checkStatusOk
)
// This new authorization request should send us to the login page.
v
=
make
(
url
.
Values
)
v
.
Set
(
"s"
,
"service.example.com/"
)
v
.
Set
(
"d"
,
"https://service.example.com/admin/"
)
v
.
Set
(
"n"
,
"averysecretnonce"
)
doGet
(
t
,
httpSrv
,
c
,
"/?"
+
v
.
Encode
(),
checkStatusOk
,
checkLoginPasswordPage
)
}
func
TestHTTP_LoginOTP
(
t
*
testing
.
T
)
{
tmpdir
,
httpSrv
:=
startTestHTTPServer
(
t
)
defer
os
.
RemoveAll
(
tmpdir
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment