@@ -13,6 +13,8 @@ import (
13
13
"golang.org/x/oauth2"
14
14
"gopkg.in/square/go-jose.v2"
15
15
"gopkg.in/square/go-jose.v2/jwt"
16
+
17
+ "github.com/grafana/grafana/pkg/services/featuremgmt"
16
18
)
17
19
18
20
func trueBoolPtr () * bool {
@@ -54,7 +56,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
54
56
ID : "1234" ,
55
57
},
56
58
fields : fields {
57
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Viewer" , false ),
59
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Viewer" , false , * featuremgmt . WithFeatures () ),
58
60
},
59
61
want : & BasicUserInfo {
60
62
Id : "1234" ,
@@ -93,7 +95,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
93
95
ID : "1234" ,
94
96
},
95
97
fields : fields {
96
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Viewer" , false ),
98
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Viewer" , false , * featuremgmt . WithFeatures () ),
97
99
},
98
100
want : & BasicUserInfo {
99
101
Id : "1234" ,
@@ -143,7 +145,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
143
145
{
144
146
name : "Only other roles" ,
145
147
fields : fields {
146
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Viewer" , false ),
148
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Viewer" , false , * featuremgmt . WithFeatures () ),
147
149
},
148
150
claims : & azureClaims {
149
151
@@ -171,7 +173,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
171
173
ID : "1234" ,
172
174
},
173
175
fields : fields {
174
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Editor" , false ),
176
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "Editor" , false , * featuremgmt . WithFeatures () ),
175
177
},
176
178
want : & BasicUserInfo {
177
179
Id : "1234" ,
@@ -220,7 +222,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
220
222
},
221
223
{
222
224
name : "Grafana Admin but setting is disabled" ,
223
- fields : fields {SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : false }, "Editor" , false )},
225
+ fields : fields {SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : false }, "Editor" , false , * featuremgmt . WithFeatures () )},
224
226
claims : & azureClaims {
225
227
226
228
PreferredUsername : "" ,
@@ -242,7 +244,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
242
244
name : "Editor roles in claim and GrafanaAdminAssignment enabled" ,
243
245
fields : fields {
244
246
SocialBase : newSocialBase ("azuread" ,
245
- & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : true }, "" , false )},
247
+ & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : true }, "" , false , * featuremgmt . WithFeatures () )},
246
248
claims : & azureClaims {
247
249
248
250
PreferredUsername : "" ,
@@ -263,7 +265,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
263
265
{
264
266
name : "Grafana Admin and Editor roles in claim" ,
265
267
fields : fields {SocialBase : newSocialBase ("azuread" ,
266
- & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : true }, "" , false )},
268
+ & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : true }, "" , false , * featuremgmt . WithFeatures () )},
267
269
claims : & azureClaims {
268
270
269
271
PreferredUsername : "" ,
@@ -302,7 +304,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
302
304
fields : fields {
303
305
allowedGroups : []string {"foo" , "bar" },
304
306
SocialBase : newSocialBase ("azuread" ,
305
- & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : false }, "Viewer" , false ),
307
+ & oauth2.Config {}, & OAuthInfo {AllowAssignGrafanaAdmin : false }, "Viewer" , false , * featuremgmt . WithFeatures () ),
306
308
},
307
309
claims : & azureClaims {
308
310
@@ -324,7 +326,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
324
326
{
325
327
name : "Fetch groups when ClaimsNames and ClaimsSources is set" ,
326
328
fields : fields {
327
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "" , false ),
329
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "" , false , * featuremgmt . WithFeatures () ),
328
330
},
329
331
claims : & azureClaims {
330
332
ID : "1" ,
@@ -349,7 +351,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
349
351
{
350
352
name : "Fetch groups when forceUseGraphAPI is set" ,
351
353
fields : fields {
352
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "" , false ),
354
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "" , false , * featuremgmt . WithFeatures () ),
353
355
forceUseGraphAPI : true ,
354
356
},
355
357
claims : & azureClaims {
@@ -376,7 +378,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
376
378
{
377
379
name : "Fetch empty role when strict attribute role is true and no match" ,
378
380
fields : fields {
379
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {RoleAttributeStrict : true }, "" , false ),
381
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {RoleAttributeStrict : true }, "" , false , * featuremgmt . WithFeatures () ),
380
382
},
381
383
claims : & azureClaims {
382
384
@@ -392,7 +394,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
392
394
{
393
395
name : "Fetch empty role when strict attribute role is true and no role claims returned" ,
394
396
fields : fields {
395
- SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {RoleAttributeStrict : true }, "" , false ),
397
+ SocialBase : newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {RoleAttributeStrict : true }, "" , false , * featuremgmt . WithFeatures () ),
396
398
},
397
399
claims : & azureClaims {
398
400
@@ -416,7 +418,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
416
418
}
417
419
418
420
if tt .fields .SocialBase == nil {
419
- s .SocialBase = newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "" , false )
421
+ s .SocialBase = newSocialBase ("azuread" , & oauth2.Config {}, & OAuthInfo {}, "" , false , * featuremgmt . WithFeatures () )
420
422
}
421
423
422
424
key := []byte ("secret" )
0 commit comments