@@ -9,31 +9,38 @@ import Connection from './index.js';
99import { WeaviateStartUpError } from '../errors.js' ;
1010import weaviate from '../index.js' ;
1111
12- describe ( 'connection' , ( ) => {
13- it ( 'makes a logged-in request when client host param has trailing slashes' , async ( ) => {
14- if ( process . env . WCS_DUMMY_CI_PW == undefined || process . env . WCS_DUMMY_CI_PW == '' ) {
15- console . warn ( 'Skipping because `WCS_DUMMY_CI_PW` is not set' ) ;
16- return Promise . resolve ( ) ;
17- }
18-
19- const client = await weaviate . connectToLocal ( {
20- port : 8085 ,
21- authCredentials : new AuthUserPasswordCredentials ( {
22- username : 'oidc-test-user@weaviate.io' ,
23- password : process . env . WCS_DUMMY_CI_PW ,
24- silentRefresh : false ,
25- } ) ,
26- } ) ;
12+ const check = ( cred ?: string ) => {
13+ if ( cred == undefined || cred == '' ) {
14+ console . warn ( 'Skipping because `WCS_DUMMY_CI_PW` is not set' ) ;
15+ return it . skip ;
16+ } else {
17+ return it ;
18+ }
19+ } ;
2720
28- return client
29- . getMeta ( )
30- . then ( ( res ) => {
31- expect ( res . version ) . toBeDefined ( ) ;
32- } )
33- . catch ( ( e ) => {
34- throw new Error ( 'it should not have errord: ' + e ) ;
21+ describe ( 'connection' , ( ) => {
22+ check ( process . env . WCS_DUMMY_CI_PW ) (
23+ 'makes a logged-in request when client host param has trailing slashes' ,
24+ async ( ) => {
25+ const client = await weaviate . connectToLocal ( {
26+ port : 8085 ,
27+ authCredentials : new AuthUserPasswordCredentials ( {
28+ username : 'oidc-test-user@weaviate.io' ,
29+ password : process . env . WCS_DUMMY_CI_PW ,
30+ silentRefresh : false ,
31+ } ) ,
3532 } ) ;
36- } ) ;
33+
34+ return client
35+ . getMeta ( )
36+ . then ( ( res ) => {
37+ expect ( res . version ) . toBeDefined ( ) ;
38+ } )
39+ . catch ( ( e ) => {
40+ throw new Error ( 'it should not have errord: ' + e ) ;
41+ } ) ;
42+ }
43+ ) ;
3744
3845 // it('makes an Azure logged-in request with client credentials', async () => {
3946 // if (process.env.AZURE_CLIENT_SECRET == undefined || process.env.AZURE_CLIENT_SECRET == '') {
@@ -59,37 +66,30 @@ describe('connection', () => {
5966 // });
6067 // });
6168
62- it ( 'makes an Okta logged-in request with client credentials' , async ( ) => {
63- if ( process . env . OKTA_CLIENT_SECRET == undefined || process . env . OKTA_CLIENT_SECRET == '' ) {
64- console . warn ( 'Skipping because `OKTA_CLIENT_SECRET` is not set' ) ;
65- return Promise . resolve ( ) ;
66- }
67-
68- const client = await weaviate . connectToLocal ( {
69- port : 8082 ,
70- authCredentials : new AuthClientCredentials ( {
71- clientSecret : process . env . OKTA_CLIENT_SECRET ,
72- scopes : [ 'some_scope' ] ,
73- silentRefresh : false ,
74- } ) ,
75- } ) ;
76-
77- return client
78- . getMeta ( )
79- . then ( ( res ) => {
80- expect ( res . version ) . toBeDefined ( ) ;
81- } )
82- . catch ( ( e ) => {
83- throw new Error ( 'it should not have errord: ' + e ) ;
69+ check ( process . env . OKTA_CLIENT_SECRET ) (
70+ 'makes an Okta logged-in request with client credentials' ,
71+ async ( ) => {
72+ const client = await weaviate . connectToLocal ( {
73+ port : 8082 ,
74+ authCredentials : new AuthClientCredentials ( {
75+ clientSecret : process . env . OKTA_CLIENT_SECRET ! ,
76+ scopes : [ 'some_scope' ] ,
77+ silentRefresh : false ,
78+ } ) ,
8479 } ) ;
85- } ) ;
8680
87- it ( 'makes an Okta logged-in request with username/password' , async ( ) => {
88- if ( process . env . OKTA_DUMMY_CI_PW == undefined || process . env . OKTA_DUMMY_CI_PW == '' ) {
89- console . warn ( 'Skipping because `OKTA_DUMMY_CI_PW` is not set' ) ;
90- return Promise . resolve ( ) ;
81+ return client
82+ . getMeta ( )
83+ . then ( ( res ) => {
84+ expect ( res . version ) . toBeDefined ( ) ;
85+ } )
86+ . catch ( ( e ) => {
87+ throw new Error ( 'it should not have errord: ' + e ) ;
88+ } ) ;
9189 }
90+ ) ;
9291
92+ check ( process . env . OKTA_DUMMY_CI_PW ) ( 'makes an Okta logged-in request with username/password' , async ( ) => {
9393 const client = await weaviate . connectToLocal ( {
9494 port : 8083 ,
9595 authCredentials : new AuthUserPasswordCredentials ( {
@@ -109,12 +109,7 @@ describe('connection', () => {
109109 } ) ;
110110 } ) ;
111111
112- it ( 'makes a WCS logged-in request with username/password' , async ( ) => {
113- if ( process . env . WCS_DUMMY_CI_PW == undefined || process . env . WCS_DUMMY_CI_PW == '' ) {
114- console . warn ( 'Skipping because `WCS_DUMMY_CI_PW` is not set' ) ;
115- return Promise . resolve ( ) ;
116- }
117-
112+ check ( process . env . WCS_DUMMY_CI_PW ) ( 'makes a WCS logged-in request with username/password' , async ( ) => {
118113 const client = await weaviate . connectToLocal ( {
119114 port : 8085 ,
120115 authCredentials : new AuthUserPasswordCredentials ( {
@@ -137,6 +132,7 @@ describe('connection', () => {
137132 it ( 'makes a logged-in request with API key' , async ( ) => {
138133 const client = await weaviate . connectToLocal ( {
139134 port : 8085 ,
135+ grpcPort : 50056 ,
140136 authCredentials : new ApiKey ( 'my-secret-key' ) ,
141137 } ) ;
142138
@@ -153,6 +149,7 @@ describe('connection', () => {
153149 it ( 'makes a logged-in request with API key as string' , async ( ) => {
154150 const client = await weaviate . connectToLocal ( {
155151 port : 8085 ,
152+ grpcPort : 50056 ,
156153 authCredentials : 'my-secret-key' ,
157154 } ) ;
158155
@@ -166,12 +163,7 @@ describe('connection', () => {
166163 } ) ;
167164 } ) ;
168165
169- it ( 'makes a logged-in request with access token' , async ( ) => {
170- if ( process . env . WCS_DUMMY_CI_PW == undefined || process . env . WCS_DUMMY_CI_PW == '' ) {
171- console . warn ( 'Skipping because `WCS_DUMMY_CI_PW` is not set' ) ;
172- return ;
173- }
174-
166+ check ( process . env . WCS_DUMMY_CI_PW ) ( 'makes a logged-in request with access token' , async ( ) => {
175167 const dummy = new Connection ( {
176168 scheme : 'http' ,
177169 host : 'localhost:8085' ,
@@ -188,6 +180,7 @@ describe('connection', () => {
188180 const accessToken = ( dummy as any ) . oidcAuth ?. accessToken || '' ;
189181 const client = await weaviate . connectToLocal ( {
190182 port : 8085 ,
183+ grpcPort : 50056 ,
191184 authCredentials : new AuthAccessTokenCredentials ( {
192185 accessToken : accessToken ,
193186 expiresIn : 900 ,
@@ -205,12 +198,7 @@ describe('connection', () => {
205198 } ) ;
206199 } ) ;
207200
208- it ( 'uses refresh token to fetch new access token' , async ( ) => {
209- if ( process . env . WCS_DUMMY_CI_PW == undefined || process . env . WCS_DUMMY_CI_PW == '' ) {
210- console . warn ( 'Skipping because `WCS_DUMMY_CI_PW` is not set' ) ;
211- return ;
212- }
213-
201+ check ( process . env . WCS_DUMMY_CI_PW ) ( 'uses refresh token to fetch new access token' , async ( ) => {
214202 const dummy = new Connection ( {
215203 scheme : 'http' ,
216204 host : 'localhost:8085' ,
@@ -237,23 +225,22 @@ describe('connection', () => {
237225 // force the use of refreshToken
238226 ( conn as any ) . oidcAuth ?. resetExpiresAt ( ) ;
239227
240- return conn
241- . login ( )
242- . then ( ( resp ) => {
243- expect ( resp ) . toBeDefined ( ) ;
244- expect ( resp != '' ) . toBeTruthy ( ) ;
245- conn . oidcAuth ?. stopTokenRefresh ( ) ;
246- } )
247- . catch ( ( e : any ) => {
248- throw new Error ( 'it should not have errord: ' + e ) ;
249- } ) ;
228+ return conn . login ( ) . then ( ( resp ) => {
229+ expect ( resp ) . toBeDefined ( ) ;
230+ expect ( resp != '' ) . toBeTruthy ( ) ;
231+ conn . oidcAuth ?. stopTokenRefresh ( ) ;
232+ } ) ;
233+ // .catch((e: any) => {
234+ // throw new Error('it should not have errord: ' + e);
235+ // });
250236 } ) ;
251237
252238 it ( 'fails to access auth-enabled server without client auth' , async ( ) => {
253239 expect . assertions ( 3 ) ;
254240 try {
255241 await weaviate . connectToLocal ( {
256242 port : 8085 ,
243+ grpcPort : 50056 ,
257244 } ) ;
258245 throw new Error ( 'Promise should have been rejected' ) ;
259246 } catch ( error : any ) {
0 commit comments