Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ai3
accountserver
Commits
3cbaad14
Commit
3cbaad14
authored
Oct 29, 2018
by
ale
Browse files
Test /api/user/get with varying group memberships
parent
2f146082
Changes
1
Hide whitespace changes
Inline
Side-by-side
integrationtest/integration_test.go
View file @
3cbaad14
...
...
@@ -59,9 +59,8 @@ type testClient struct {
signer
sso
.
Signer
}
func
(
c
*
testClient
)
ssoTicket
(
username
string
)
string
{
var
groups
[]
string
if
username
==
testAdminUser
{
func
(
c
*
testClient
)
ssoTicket
(
username
string
,
groups
...
string
)
string
{
if
len
(
groups
)
==
0
&&
username
==
testAdminUser
{
groups
=
append
(
groups
,
testAdminGroup
)
}
signed
,
err
:=
c
.
signer
.
Sign
(
sso
.
NewTicket
(
username
,
testSSOService
,
testSSODomain
,
""
,
groups
,
1
*
time
.
Hour
))
...
...
@@ -164,19 +163,25 @@ func TestIntegration_GetUser_Auth(t *testing.T) {
testdata
:=
[]
struct
{
authUser
string
authGroup
string
expectedOk
bool
}{
{
"uno@investici.org"
,
true
},
{
"due@investici.org"
,
false
},
{
testAdminUser
,
true
},
{
"uno@investici.org"
,
""
,
true
},
{
"uno@investici.org"
,
"users"
,
true
},
{
"due@investici.org"
,
"users"
,
false
},
{
testAdminUser
,
testAdminGroup
,
true
},
}
for
_
,
td
:=
range
testdata
{
var
user
accountserver
.
User
var
groups
[]
string
if
td
.
authGroup
!=
""
{
groups
=
append
(
groups
,
td
.
authGroup
)
}
err
:=
c
.
request
(
"/api/user/get"
,
&
accountserver
.
GetUserRequest
{
RequestBase
:
accountserver
.
RequestBase
{
Username
:
"uno@investici.org"
,
SSO
:
c
.
ssoTicket
(
td
.
authUser
),
SSO
:
c
.
ssoTicket
(
td
.
authUser
,
groups
...
),
},
},
&
user
)
if
td
.
expectedOk
&&
err
!=
nil
{
...
...
Write
Preview
Supports
Markdown
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