1414 */
1515const {
1616 printPath,
17- setupST,
18- startST,
19- killAllST,
20- cleanST,
17+
18+ createCoreApplication,
19+
2120 extractInfoFromResponse,
22- setKeyValueInConfig ,
21+
2322 delay,
2423} = require ( "./utils" ) ;
2524const assert = require ( "assert" ) ;
@@ -37,25 +36,19 @@ const exampleJWT =
3736
3837describe ( `auth-modes: ${ printPath ( "[test/auth-modes.test.js]" ) } ` , function ( ) {
3938 beforeEach ( async function ( ) {
40- await killAllST ( ) ;
41- await setupST ( ) ;
4239 ProcessState . getInstance ( ) . reset ( ) ;
4340 } ) ;
4441
4542 afterEach ( function ( ) {
4643 sinon . restore ( ) ;
4744 } ) ;
4845
49- after ( async function ( ) {
50- await killAllST ( ) ;
51- await cleanST ( ) ;
52- } ) ;
53-
5446 describe ( "with default getTokenTransferMethod" , ( ) => {
5547 describe ( "createNewSession" , ( ) => {
5648 describe ( "with default getTokenTransferMethod" , ( ) => {
5749 it ( "should default to header based session w/ no auth-mode header" , async function ( ) {
58- const connectionURI = await startST ( ) ;
50+ const connectionURI = await createCoreApplication ( ) ;
51+
5952 SuperTokens . init ( {
6053 supertokens : {
6154 connectionURI,
@@ -79,7 +72,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
7972 } ) ;
8073
8174 it ( "should default to header based session w/ bad auth-mode header" , async function ( ) {
82- const connectionURI = await startST ( ) ;
75+ const connectionURI = await createCoreApplication ( ) ;
8376 SuperTokens . init ( {
8477 supertokens : {
8578 connectionURI,
@@ -103,7 +96,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
10396 } ) ;
10497
10598 it ( "should use headers if auth-mode specifies it" , async function ( ) {
106- const connectionURI = await startST ( ) ;
99+ const connectionURI = await createCoreApplication ( ) ;
107100 SuperTokens . init ( {
108101 supertokens : {
109102 connectionURI,
@@ -127,7 +120,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
127120 } ) ;
128121
129122 it ( "should use cookies if auth-mode specifies it" , async function ( ) {
130- const connectionURI = await startST ( ) ;
123+ const connectionURI = await createCoreApplication ( ) ;
131124 SuperTokens . init ( {
132125 supertokens : {
133126 connectionURI,
@@ -157,7 +150,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
157150
158151 describe ( "with user provided getTokenTransferMethod" , ( ) => {
159152 it ( "should use headers if getTokenTransferMethod returns any and there is no st-auth-mode header" , async function ( ) {
160- const connectionURI = await startST ( ) ;
153+ const connectionURI = await createCoreApplication ( ) ;
161154 SuperTokens . init ( {
162155 supertokens : {
163156 connectionURI,
@@ -181,7 +174,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
181174 } ) ;
182175
183176 it ( "should use cookies if getTokenTransferMethod returns any and st-auth-mode is set to cookie" , async function ( ) {
184- const connectionURI = await startST ( ) ;
177+ const connectionURI = await createCoreApplication ( ) ;
185178 SuperTokens . init ( {
186179 supertokens : {
187180 connectionURI,
@@ -205,7 +198,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
205198 } ) ;
206199
207200 it ( "should use headers if getTokenTransferMethod returns any and st-auth-mode is set to header" , async function ( ) {
208- const connectionURI = await startST ( ) ;
201+ const connectionURI = await createCoreApplication ( ) ;
209202 SuperTokens . init ( {
210203 supertokens : {
211204 connectionURI,
@@ -229,7 +222,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
229222 } ) ;
230223
231224 it ( "should use headers if getTokenTransferMethod returns header" , async function ( ) {
232- const connectionURI = await startST ( ) ;
225+ const connectionURI = await createCoreApplication ( ) ;
233226 SuperTokens . init ( {
234227 supertokens : {
235228 connectionURI,
@@ -253,7 +246,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
253246 } ) ;
254247
255248 it ( "should use clear cookies (if present) if getTokenTransferMethod returns header" , async function ( ) {
256- const connectionURI = await startST ( ) ;
249+ const connectionURI = await createCoreApplication ( ) ;
257250 SuperTokens . init ( {
258251 supertokens : {
259252 connectionURI,
@@ -293,7 +286,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
293286 } ) ;
294287
295288 it ( "should use cookies if getTokenTransferMethod returns cookie" , async function ( ) {
296- const connectionURI = await startST ( ) ;
289+ const connectionURI = await createCoreApplication ( ) ;
297290 SuperTokens . init ( {
298291 supertokens : {
299292 connectionURI,
@@ -321,7 +314,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
321314 } ) ;
322315
323316 it ( "should clear headers (if present) if getTokenTransferMethod returns cookie" , async function ( ) {
324- const connectionURI = await startST ( ) ;
317+ const connectionURI = await createCoreApplication ( ) ;
325318 SuperTokens . init ( {
326319 supertokens : {
327320 connectionURI,
@@ -393,7 +386,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
393386 for ( let i = 0 ; i < behaviourTable . length ; ++ i ) {
394387 const conf = behaviourTable [ i ] ;
395388 it ( `should match line ${ i + 1 } with a valid token` , async ( ) => {
396- const connectionURI = await startST ( ) ;
389+ const connectionURI = await createCoreApplication ( ) ;
397390 SuperTokens . init ( {
398391 supertokens : {
399392 connectionURI,
@@ -445,7 +438,8 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
445438 } ) ;
446439
447440 it ( `should match line ${ i + 1 } with a expired token` , async ( ) => {
448- const connectionURI = await startST ( { coreConfig : { access_token_validity : 2 } } ) ;
441+ const connectionURI = await createCoreApplication ( { coreConfig : { access_token_validity : 2 } } ) ;
442+
449443 SuperTokens . init ( {
450444 supertokens : {
451445 connectionURI,
@@ -500,7 +494,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
500494
501495 describe ( "with access tokens in both headers and cookies" , ( ) => {
502496 it ( "should use the value from headers if getTokenTransferMethod returns any" , async ( ) => {
503- const connectionURI = await startST ( ) ;
497+ const connectionURI = await createCoreApplication ( ) ;
504498 SuperTokens . init ( {
505499 supertokens : {
506500 connectionURI,
@@ -547,7 +541,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
547541 } ) ;
548542
549543 it ( "should use the value from headers if getTokenTransferMethod returns header" , async ( ) => {
550- const connectionURI = await startST ( ) ;
544+ const connectionURI = await createCoreApplication ( ) ;
551545 SuperTokens . init ( {
552546 supertokens : {
553547 connectionURI,
@@ -595,7 +589,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
595589 } ) ;
596590
597591 it ( "should use the value from cookies if getTokenTransferMethod returns cookie" , async ( ) => {
598- const connectionURI = await startST ( ) ;
592+ const connectionURI = await createCoreApplication ( ) ;
599593 SuperTokens . init ( {
600594 supertokens : {
601595 connectionURI,
@@ -644,7 +638,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
644638 } ) ;
645639
646640 it ( "should reject requests with sIdRefreshToken" , async ( ) => {
647- const connectionURI = await startST ( ) ;
641+ const connectionURI = await createCoreApplication ( ) ;
648642 SuperTokens . init ( {
649643 supertokens : {
650644 connectionURI,
@@ -687,7 +681,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
687681
688682 describe ( "with non ST in Authorize header" , ( ) => {
689683 it ( "should use the value from cookies if present and getTokenTransferMethod returns any" , async ( ) => {
690- const connectionURI = await startST ( ) ;
684+ const connectionURI = await createCoreApplication ( ) ;
691685 SuperTokens . init ( {
692686 supertokens : {
693687 connectionURI,
@@ -730,7 +724,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
730724 } ) ;
731725
732726 it ( "should reject with UNAUTHORISED if getTokenTransferMethod returns header" , async ( ) => {
733- const connectionURI = await startST ( ) ;
727+ const connectionURI = await createCoreApplication ( ) ;
734728 SuperTokens . init ( {
735729 supertokens : {
736730 connectionURI,
@@ -774,7 +768,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
774768 } ) ;
775769
776770 it ( "should reject with UNAUTHORISED if cookies are not present" , async ( ) => {
777- const connectionURI = await startST ( ) ;
771+ const connectionURI = await createCoreApplication ( ) ;
778772 SuperTokens . init ( {
779773 supertokens : {
780774 connectionURI,
@@ -815,7 +809,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
815809
816810 describe ( "mergeIntoAccessTokenPayload" , ( ) => {
817811 it ( "should update cookies if the session was cookie based" , async function ( ) {
818- const connectionURI = await startST ( ) ;
812+ const connectionURI = await createCoreApplication ( ) ;
819813 SuperTokens . init ( {
820814 supertokens : {
821815 connectionURI,
@@ -852,7 +846,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
852846 } ) ;
853847
854848 it ( "should allow headers if the session was header based" , async function ( ) {
855- const connectionURI = await startST ( ) ;
849+ const connectionURI = await createCoreApplication ( ) ;
856850 SuperTokens . init ( {
857851 supertokens : {
858852 connectionURI,
@@ -910,7 +904,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
910904 for ( let i = 0 ; i < behaviourTable . length ; ++ i ) {
911905 const conf = behaviourTable [ i ] ;
912906 it ( `should match line ${ i + 1 } with a valid token` , async ( ) => {
913- const connectionURI = await startST ( ) ;
907+ const connectionURI = await createCoreApplication ( ) ;
914908 SuperTokens . init ( {
915909 supertokens : {
916910 connectionURI,
@@ -1011,7 +1005,7 @@ describe(`auth-modes: ${printPath("[test/auth-modes.test.js]")}`, function () {
10111005 const conf = behaviourTable [ i ] ;
10121006
10131007 it ( `should match line ${ i + 1 } with a invalid token` , async ( ) => {
1014- const connectionURI = await startST ( ) ;
1008+ const connectionURI = await createCoreApplication ( ) ;
10151009 SuperTokens . init ( {
10161010 supertokens : {
10171011 connectionURI,
0 commit comments