@@ -2,7 +2,11 @@ import * as communication from '../../src/internal/communication';
2
2
import { errorLibraryNotInitialized } from '../../src/internal/constants' ;
3
3
import { app , FrameContexts , HostClientType , nestedAppAuth } from '../../src/public' ;
4
4
import { errorNotSupportedOnPlatform } from '../../src/public/constants' ;
5
- import { _minRuntimeConfigToUninitialize , Runtime } from '../../src/public/runtime' ;
5
+ import {
6
+ _minRuntimeConfigToUninitialize ,
7
+ Runtime ,
8
+ legacyTeamsMobileVersionForDeeplyNestedAuth ,
9
+ } from '../../src/public/runtime' ;
6
10
import { Utils } from '../utils' ;
7
11
8
12
/* eslint-disable */
@@ -125,84 +129,143 @@ describe('nestedAppAuth', () => {
125
129
} ) ;
126
130
} ) ;
127
131
} ) ;
128
- describe ( 'canParentManageNAATrustedOrigins' , ( ) => {
132
+
133
+ describe ( 'isDeeplyNestedAuthSupported' , ( ) => {
129
134
it ( 'should throw if called before initialization' , ( ) => {
130
135
utils . uninitializeRuntimeConfig ( ) ;
131
- expect ( ( ) => nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toThrowError (
132
- new Error ( errorLibraryNotInitialized ) ,
133
- ) ;
136
+ expect ( ( ) => nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toThrowError ( new Error ( errorLibraryNotInitialized ) ) ;
134
137
} ) ;
135
138
136
- it ( 'should return true if canParentManageNAATrustedOrigins set to true in runtime object' , async ( ) => {
139
+ it ( 'should return true if isDeeplyNestedAuthSupported set to true in runtime object' , async ( ) => {
137
140
await utils . initializeWithContext ( FrameContexts . content ) ;
138
141
const runtimeConfig : Runtime = {
139
142
apiVersion : 4 ,
140
143
supports : { } ,
141
- canParentManageNAATrustedOrigins : true ,
144
+ isDeeplyNestedAuthSupported : true ,
142
145
} ;
143
146
utils . setRuntimeConfig ( runtimeConfig ) ;
144
- expect ( nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toBeTruthy ( ) ;
147
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeTruthy ( ) ;
145
148
} ) ;
146
149
147
- it ( 'should return false if canParentManageNAATrustedOrigins set to false in runtime object ' , async ( ) => {
150
+ it ( 'should return false if isDeeplyNestedAuthSupported set to false in runtime object ' , async ( ) => {
148
151
await utils . initializeWithContext ( FrameContexts . content ) ;
149
152
const runtimeConfig : Runtime = {
150
153
apiVersion : 4 ,
151
154
supports : { } ,
152
- canParentManageNAATrustedOrigins : false ,
155
+ isDeeplyNestedAuthSupported : false ,
153
156
} ;
154
157
utils . setRuntimeConfig ( runtimeConfig ) ;
155
- expect ( nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toBeFalsy ( ) ;
158
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
156
159
} ) ;
157
160
158
- it ( 'should return false if canParentManageNAATrustedOrigins not present in runtime object ' , async ( ) => {
161
+ it ( 'should return false if isDeeplyNestedAuthSupported not present in runtime object ' , async ( ) => {
159
162
await utils . initializeWithContext ( FrameContexts . content ) ;
160
163
const runtimeConfig : Runtime = {
161
164
apiVersion : 4 ,
162
165
supports : { } ,
163
166
} ;
164
167
utils . setRuntimeConfig ( runtimeConfig ) ;
165
- expect ( nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toBeFalsy ( ) ;
168
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
169
+ } ) ;
170
+
171
+ describe ( 'should return false when isDeeplyNestedAuthSupported is false across different host clients' , ( ) => {
172
+ const hostClients = [ HostClientType . macos , HostClientType . desktop , HostClientType . web ] ;
173
+
174
+ hostClients . forEach ( ( hostClient ) => {
175
+ it ( `${ hostClient } client` , async ( ) => {
176
+ await utils . initializeWithContext ( FrameContexts . content , hostClient ) ;
177
+ const runtimeConfig : Runtime = {
178
+ apiVersion : 4 ,
179
+ supports : { } ,
180
+ isDeeplyNestedAuthSupported : false ,
181
+ } ;
182
+ utils . setRuntimeConfig ( runtimeConfig ) ;
183
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
184
+ } ) ;
185
+ } ) ;
186
+ } ) ;
187
+
188
+ it ( 'should return false if isDeeplyNestedAuthSupported is false and isLegacyTeams is false in runtimeConfig' , async ( ) => {
189
+ await utils . initializeWithContext ( FrameContexts . content , HostClientType . android ) ;
190
+ const runtimeConfig : Runtime = {
191
+ apiVersion : 4 ,
192
+ supports : { } ,
193
+ isDeeplyNestedAuthSupported : false ,
194
+ isLegacyTeams : false ,
195
+ } ;
196
+ utils . setRuntimeConfig ( runtimeConfig ) ;
197
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
198
+ } ) ;
199
+
200
+ it ( 'should return false if isDeeplyNestedAuthSupported is false and isLegacyTeams is true in runtimeConfig for android client for version < legacyTeamsMobileVersionForDeeplyNestedAuth' , async ( ) => {
201
+ await utils . initializeWithContext ( FrameContexts . content , HostClientType . android ) ;
202
+ const runtimeConfig : Runtime = {
203
+ apiVersion : 4 ,
204
+ supports : { } ,
205
+ isDeeplyNestedAuthSupported : false ,
206
+ isLegacyTeams : true ,
207
+ } ;
208
+ utils . setClientSupportedSDKVersion ( '2.1.1' ) ;
209
+ utils . setRuntimeConfig ( runtimeConfig ) ;
210
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
211
+ } ) ;
212
+
213
+ describe ( 'should return true if isDeeplyNestedAuthSupported is false and isLegacyTeams is true in runtimeConfig for android clients with version legacyTeamsMobileVersionForDeeplyNestedAuth' , ( ) => {
214
+ const hostClients = [ HostClientType . ipados , HostClientType . ios , HostClientType . android ] ;
215
+ hostClients . forEach ( ( hostClient ) => {
216
+ it ( `for ${ hostClient } client` , async ( ) => {
217
+ await utils . initializeWithContext ( FrameContexts . content , hostClient ) ;
218
+ utils . setClientSupportedSDKVersion ( legacyTeamsMobileVersionForDeeplyNestedAuth ) ;
219
+ const runtimeConfig : Runtime = {
220
+ apiVersion : 4 ,
221
+ supports : { } ,
222
+ isDeeplyNestedAuthSupported : false ,
223
+ isLegacyTeams : true ,
224
+ } ;
225
+ utils . setRuntimeConfig ( runtimeConfig ) ;
226
+ expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeTruthy ( ) ;
227
+ } ) ;
228
+ } ) ;
166
229
} ) ;
167
230
} ) ;
168
- describe ( 'nestedAppAuth.isDeeplyNestedAuthSupported ' , ( ) => {
231
+ describe ( 'canParentManageNAATrustedOrigins ' , ( ) => {
169
232
it ( 'should throw if called before initialization' , ( ) => {
170
233
utils . uninitializeRuntimeConfig ( ) ;
171
- expect ( ( ) => nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toThrowError ( new Error ( errorLibraryNotInitialized ) ) ;
234
+ expect ( ( ) => nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toThrowError (
235
+ new Error ( errorLibraryNotInitialized ) ,
236
+ ) ;
172
237
} ) ;
173
238
174
- it ( 'should return true if isDeeplyNestedAuthSupported set to true in runtime object' , async ( ) => {
239
+ it ( 'should return true if canParentManageNAATrustedOrigins set to true in runtime object' , async ( ) => {
175
240
await utils . initializeWithContext ( FrameContexts . content ) ;
176
241
const runtimeConfig : Runtime = {
177
242
apiVersion : 4 ,
178
243
supports : { } ,
179
- isNAAChannelRecommended : true ,
180
- isDeeplyNestedAuthSupported : true ,
244
+ canParentManageNAATrustedOrigins : true ,
181
245
} ;
182
246
utils . setRuntimeConfig ( runtimeConfig ) ;
183
- expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeTruthy ( ) ;
247
+ expect ( nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toBeTruthy ( ) ;
184
248
} ) ;
185
249
186
- it ( 'should return false if isDeeplyNestedAuthSupported set to false in runtime object ' , async ( ) => {
250
+ it ( 'should return false if canParentManageNAATrustedOrigins set to false in runtime object ' , async ( ) => {
187
251
await utils . initializeWithContext ( FrameContexts . content ) ;
188
252
const runtimeConfig : Runtime = {
189
253
apiVersion : 4 ,
190
254
supports : { } ,
191
- isNAAChannelRecommended : false ,
255
+ canParentManageNAATrustedOrigins : false ,
192
256
} ;
193
257
utils . setRuntimeConfig ( runtimeConfig ) ;
194
- expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
258
+ expect ( nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toBeFalsy ( ) ;
195
259
} ) ;
196
260
197
- it ( 'should return false if isDeeplyNestedAuthSupported not present in runtime object ' , async ( ) => {
261
+ it ( 'should return false if canParentManageNAATrustedOrigins not present in runtime object ' , async ( ) => {
198
262
await utils . initializeWithContext ( FrameContexts . content ) ;
199
263
const runtimeConfig : Runtime = {
200
264
apiVersion : 4 ,
201
265
supports : { } ,
202
- isNAAChannelRecommended : true ,
203
266
} ;
204
267
utils . setRuntimeConfig ( runtimeConfig ) ;
205
- expect ( nestedAppAuth . isDeeplyNestedAuthSupported ( ) ) . toBeFalsy ( ) ;
268
+ expect ( nestedAppAuth . canParentManageNAATrustedOrigins ( ) ) . toBeFalsy ( ) ;
206
269
} ) ;
207
270
} ) ;
208
271
describe ( 'getParentOrigin' , ( ) => {
0 commit comments