Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
accountserver
Commits
3cbaad14
Commit
3cbaad14
authored
Oct 29, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test /api/user/get with varying group memberships
parent
2f146082
Pipeline
#1421
passed with stages
in 1 minute and 39 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
integrationtest/integration_test.go
integrationtest/integration_test.go
+12
-7
No files found.
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
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