@@ -22,6 +22,35 @@ import { HelmActions } from "../../utils/helm";
22
22
import { RhdhAuthUiHack } from "../../support/api/rhdh-auth-hack" ;
23
23
24
24
let page : Page ;
25
+ const oauthFlags = [
26
+ "--set upstream.backstage.appConfig.auth.providers.github=null" ,
27
+ "--set upstream.backstage.appConfig.signInPage=microsoft" ,
28
+ "--set upstream.backstage.appConfig.auth.environment=production" ,
29
+ "--set upstream.backstage.appConfig.catalog.providers.githubOrg=null" ,
30
+ "--set upstream.backstage.appConfig.catalog.providers.keycloakOrg=null" ,
31
+ "--set global.dynamic.plugins[2].disabled=false" ,
32
+ "--set global.dynamic.plugins[3].disabled=false" ,
33
+ "--set upstream.backstage.appConfig.permission.enabled=true" ,
34
+ ] ;
35
+
36
+ const oidcFlags = [
37
+ "--set upstream.backstage.appConfig.auth.providers.github=null" ,
38
+ "--set upstream.backstage.appConfig.signInPage=oidc" ,
39
+ "--set upstream.backstage.appConfig.auth.environment=production" ,
40
+ "--set upstream.backstage.appConfig.catalog.providers.githubOrg=null" ,
41
+ "--set upstream.backstage.appConfig.catalog.providers.keycloakOrg=null" ,
42
+ "--set global.dynamic.plugins[2].disabled=false" ,
43
+ "--set global.dynamic.plugins[3].disabled=false" ,
44
+ "--set upstream.backstage.appConfig.permission.enabled=true" ,
45
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.metadataUrl=https://login.microsoftonline.com/${AUTH_PROVIDERS_AZURE_TENANT_ID}/.well-known/openid-configuration" ,
46
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.tenantId=${AUTH_PROVIDERS_AZURE_TENANT_ID}" ,
47
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.clientId=${AUTH_PROVIDERS_AZURE_CLIENT_ID}" ,
48
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.clientSecret=${AUTH_PROVIDERS_AZURE_CLIENT_SECRET}" ,
49
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.prompt=auto" ,
50
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.callbackUrl=${BASE_URL}/api/auth/oidc/handler/frame" ,
51
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.signIn.resolvers[0].resolver=emailMatchingUserEntityProfileEmail" ,
52
+ "--set upstream.backstage.appConfig.auth.providers.oidc.production.signIn.resolvers[0].dangerouslyAllowSignInWithoutUserInCatalog=true" ,
53
+ ] ;
25
54
26
55
test . describe ( "Standard authentication providers: Micorsoft Azure EntraID" , ( ) => {
27
56
test . use ( { baseURL : constants . AUTH_PROVIDERS_BASE_URL } ) ;
@@ -36,7 +65,7 @@ test.describe("Standard authentication providers: Micorsoft Azure EntraID", () =
36
65
test . beforeAll ( async ( { browser } , testInfo ) => {
37
66
test . setTimeout ( 120 * 1000 ) ;
38
67
LOGGER . info (
39
- `Staring scenario: Standard authentication providers: Micorsoft Azure EntraID: attemp #${ testInfo . retry } ` ,
68
+ `Staring scenario: Standard authentication providers: Microsoft Azure EntraID: attempt #${ testInfo . retry } ` ,
40
69
) ;
41
70
42
71
const browserSetup = await setupBrowser ( browser , testInfo ) ;
@@ -66,35 +95,6 @@ test.describe("Standard authentication providers: Micorsoft Azure EntraID", () =
66
95
test ( "Setup RHDH with Microsoft EntraID ingestion and eventually wait for the first sync" , async ( ) => {
67
96
test . setTimeout ( 600 * 1000 ) ;
68
97
const oidcFlow = false ;
69
- const oauthFlags = [
70
- "--set upstream.backstage.appConfig.auth.providers.github=null" ,
71
- "--set upstream.backstage.appConfig.signInPage=microsoft" ,
72
- "--set upstream.backstage.appConfig.auth.environment=production" ,
73
- "--set upstream.backstage.appConfig.catalog.providers.githubOrg=null" ,
74
- "--set upstream.backstage.appConfig.catalog.providers.keycloakOrg=null" ,
75
- "--set global.dynamic.plugins[2].disabled=false" ,
76
- "--set global.dynamic.plugins[3].disabled=false" ,
77
- "--set upstream.backstage.appConfig.permission.enabled=true" ,
78
- ] ;
79
-
80
- const oidcFlags = [
81
- "--set upstream.backstage.appConfig.auth.providers.github=null" ,
82
- "--set upstream.backstage.appConfig.signInPage=oidc" ,
83
- "--set upstream.backstage.appConfig.auth.environment=production" ,
84
- "--set upstream.backstage.appConfig.catalog.providers.githubOrg=null" ,
85
- "--set upstream.backstage.appConfig.catalog.providers.keycloakOrg=null" ,
86
- "--set global.dynamic.plugins[2].disabled=false" ,
87
- "--set global.dynamic.plugins[3].disabled=false" ,
88
- "--set upstream.backstage.appConfig.permission.enabled=true" ,
89
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.metadataUrl=https://login.microsoftonline.com/${AUTH_PROVIDERS_AZURE_TENANT_ID}/.well-known/openid-configuration" ,
90
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.tenantId=${AUTH_PROVIDERS_AZURE_TENANT_ID}" ,
91
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.clientId=${AUTH_PROVIDERS_AZURE_CLIENT_ID}" ,
92
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.clientSecret=${AUTH_PROVIDERS_AZURE_CLIENT_SECRET}" ,
93
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.prompt=auto" ,
94
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.callbackUrl=${BASE_URL}/api/auth/oidc/handler/frame" ,
95
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.signIn.resolvers[0].resolver=emailMatchingUserEntityProfileEmail" ,
96
- "--set upstream.backstage.appConfig.auth.providers.oidc.production.signIn.resolvers[0].dangerouslyAllowSignInWithoutUserInCatalog=true" ,
97
- ] ;
98
98
// setup RHSSO provider with user ingestion
99
99
await HelmActions . upgradeHelmChartWithWait (
100
100
constants . AUTH_PROVIDERS_RELEASE ,
@@ -110,6 +110,64 @@ test.describe("Standard authentication providers: Micorsoft Azure EntraID", () =
110
110
await waitForNextSync ( "microsoft" , syncTime ) ;
111
111
} ) ;
112
112
113
+ test ( "Set sessionDuration and confirm in auth cookie duration has been set" , async ( ) => {
114
+ LOGGER . info ( `Executing testcase: ${ test . info ( ) . title } ` ) ;
115
+
116
+ test . setTimeout ( 600 * 1000 ) ;
117
+
118
+ await HelmActions . upgradeHelmChartWithWait (
119
+ constants . AUTH_PROVIDERS_RELEASE ,
120
+ constants . AUTH_PROVIDERS_CHART ,
121
+ constants . AUTH_PROVIDERS_NAMESPACE ,
122
+ constants . AUTH_PROVIDERS_VALUES_FILE ,
123
+ constants . CHART_VERSION ,
124
+ constants . QUAY_REPO ,
125
+ constants . TAG_NAME ,
126
+ [
127
+ ...oauthFlags ,
128
+ "--set upstream.backstage.appConfig.auth.providers.microsoft.production.sessionDuration=3days" ,
129
+ ] ,
130
+ ) ;
131
+
132
+ await waitForNextSync ( "microsoft" , syncTime ) ;
133
+
134
+ await common . MicrosoftAzureLogin (
135
+ constants . MSGRAPH_USERS [ "user_1" ] . userPrincipalName ,
136
+ constants . RHSSO76_DEFAULT_PASSWORD ,
137
+ ) ;
138
+
139
+ await expect ( async ( ) => {
140
+ expect (
141
+ await common . CheckUserIsIngestedInCatalog (
142
+ [ constants . MSGRAPH_USERS [ "user_1" ] . displayName ] ,
143
+ constants . STATIC_API_TOKEN ,
144
+ ) ,
145
+ ) . toBe ( true ) ;
146
+ } ) . toPass ( {
147
+ intervals : [ 1_000 , 2_000 , 5_000 ] ,
148
+ timeout : 90 * 1000 ,
149
+ } ) ;
150
+
151
+ await page . reload ( ) ;
152
+
153
+ const cookies = await context . cookies ( ) ;
154
+ const authCookie = cookies . find (
155
+ ( cookie ) => cookie . name === "microsoft-refresh-token" ,
156
+ ) ;
157
+
158
+ const threeDays = 3 * 24 * 60 * 60 * 1000 ; // expected duration of 3 days in ms
159
+ const tolerance = 3 * 60 * 1000 ; // allow for 3 minutes tolerance
160
+
161
+ const actualDuration = authCookie . expires * 1000 - Date . now ( ) ;
162
+
163
+ expect ( actualDuration ) . toBeGreaterThan ( threeDays - tolerance ) ;
164
+ expect ( actualDuration ) . toBeLessThan ( threeDays + tolerance ) ;
165
+
166
+ await uiHelper . goToSettingsPage ( ) ;
167
+ await common . signOut ( ) ;
168
+ await context . clearCookies ( ) ;
169
+ } ) ;
170
+
113
171
test ( "Microsoft EntraID with default resolver: user_1 should login and entity is in the catalog" , async ( ) => {
114
172
// resolvers from upstream are not available in rhdh
115
173
// testing only default settings
0 commit comments