@@ -37,14 +37,43 @@ describe('custom auth', () => {
37
37
expect ( response . data . currentWorkspace ) . toHaveProperty ( 'displayName' ) ;
38
38
} ) ;
39
39
40
+ it ( 'passes authentication with api url and returns json' , async ( ) => {
41
+ const bundle = getBundle ( ) ;
42
+ const bundleWithApiUrl = {
43
+ ...bundle ,
44
+ authData : { ...bundle . authData , apiUrl : 'http://localhost:3000' } ,
45
+ } ;
46
+ const response = await appTester ( App . authentication . test , bundleWithApiUrl ) ;
47
+ expect ( response . data ) . toHaveProperty ( 'currentWorkspace' ) ;
48
+ expect ( response . data . currentWorkspace ) . toHaveProperty ( 'displayName' ) ;
49
+ } ) ;
50
+
51
+ it ( 'fail authentication with bad api url' , async ( ) => {
52
+ const bundle = getBundle ( ) ;
53
+ const bundleWithApiUrl = {
54
+ ...bundle ,
55
+ authData : { ...bundle . authData , apiUrl : 'http://invalid' } ,
56
+ } ;
57
+ try {
58
+ const response = await appTester (
59
+ App . authentication . test ,
60
+ bundleWithApiUrl ,
61
+ ) ;
62
+ expect ( response . data ) . toHaveProperty ( 'currentWorkspace' ) ;
63
+ expect ( response . data . currentWorkspace ) . toHaveProperty ( 'displayName' ) ;
64
+ } catch ( error : any ) {
65
+ expect ( error . message ) . toContain ( 'ENOTFOUND' ) ;
66
+ }
67
+ } ) ;
68
+
40
69
it ( 'fails on bad auth token format' , async ( ) => {
41
70
const bundle = getBundle ( ) ;
42
71
bundle . authData . apiKey = 'bad' ;
43
72
44
73
try {
45
74
await appTester ( App . authentication . test , bundle ) ;
46
75
} catch ( error : any ) {
47
- expect ( error . message ) . toContain ( 'Unauthenticated ' ) ;
76
+ expect ( error . message ) . toContain ( 'UNAUTHENTICATED ' ) ;
48
77
return ;
49
78
}
50
79
throw new Error ( 'appTester should have thrown' ) ;
@@ -71,7 +100,7 @@ describe('custom auth', () => {
71
100
try {
72
101
await appTester ( App . authentication . test , bundleWithExpiredApiKey ) ;
73
102
} catch ( error : any ) {
74
- expect ( error . message ) . toContain ( 'Unauthenticated ' ) ;
103
+ expect ( error . message ) . toContain ( 'UNAUTHENTICATED ' ) ;
75
104
return ;
76
105
}
77
106
throw new Error ( 'appTester should have thrown' ) ;
0 commit comments