Commit 3cbaad14 authored by ale's avatar ale

Test /api/user/get with varying group memberships

parent 2f146082
Pipeline #1421 passed with stages
in 1 minute and 39 seconds
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment