@@ -100,6 +100,39 @@ func TestHandleCallBackForGroupsInUserInfo(t *testing.T) {
100100 assert .Equal (t , identity .EmailVerified , false )
101101}
102102
103+ func TestHandleCallBackForGroupsInUserInfoIsString (t * testing.T ) {
104+ tokenClaims := map [string ]interface {}{}
105+
106+ userInfoClaims := map [string ]interface {}{
107+ "name" : "test-name" ,
108+ "user_id_key" : "test-user-id" ,
109+ "user_name_key" : "test-username" ,
110+ "preferred_username" : "test-preferred-username" ,
111+ "mail" : "mod_mail" ,
112+ "has_verified_email" : false ,
113+ "groups_key" : `["admin-group", "user-group"]` ,
114+ }
115+
116+ testServer := testSetup (t , tokenClaims , userInfoClaims )
117+ defer testServer .Close ()
118+
119+ conn := newConnector (t , testServer .URL )
120+ req := newRequestWithAuthCode (t , testServer .URL , "TestHandleCallBackForGroupsInUserInfo" )
121+
122+ identity , err := conn .HandleCallback (connector.Scopes {Groups : true }, req )
123+ assert .Equal (t , err , nil )
124+
125+ sort .Strings (identity .Groups )
126+ assert .Equal (t , len (identity .Groups ), 2 )
127+ assert .Equal (t , identity .Groups [0 ], "admin-group" )
128+ assert .Equal (t , identity .Groups [1 ], "user-group" )
129+ assert .Equal (t , identity .UserID , "test-user-id" )
130+ assert .Equal (t , identity .Username , "test-username" )
131+ assert .Equal (t , identity .PreferredUsername , "test-preferred-username" )
132+ assert .Equal (t , identity .Email , "mod_mail" )
133+ assert .Equal (t , identity .EmailVerified , false )
134+ }
135+
103136func TestHandleCallBackForGroupMapsInUserInfo (t * testing.T ) {
104137 tokenClaims := map [string ]interface {}{}
105138
0 commit comments