Skip to content

Commit 9a2fd87

Browse files
dirkkultsmith023
andauthored
Update wcs docker file to use descope (#368)
* Update wcs docker file to use descope * Update test checks * Add auth tests for trailing 3 vers also * Remove 1.34 for now * Expose grpc ports correctly in tests * Improve skipping of auth tests * Remove hard-coded refresh token error * Remove extra auth tests to avoid rate limit issues --------- Co-authored-by: Tommy Smith <tommy@weaviate.io>
1 parent 5f0a44f commit 9a2fd87

File tree

5 files changed

+73
-91
lines changed

5 files changed

+73
-91
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
fail-fast: false
8181
matrix:
8282
versions: [
83-
{ node: "22.x", weaviate: $WEAVIATE_130}
83+
{ node: "22.x", weaviate: $WEAVIATE_133},
8484
]
8585
steps:
8686
- uses: actions/checkout@v3

ci/docker-compose-wcs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ services:
1313
image: semitechnologies/weaviate:${WEAVIATE_VERSION}
1414
ports:
1515
- 8085:8085
16+
- 50056:50056
1617
restart: on-failure:0
1718
environment:
19+
GRPC_PORT: 50056
1820
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
1921
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'false'
2022
AUTHENTICATION_OIDC_ENABLED: 'true'
21-
AUTHENTICATION_OIDC_CLIENT_ID: 'wcs'
22-
AUTHENTICATION_OIDC_ISSUER: 'https://auth.wcs.api.weaviate.io/auth/realms/SeMI'
23+
AUTHENTICATION_OIDC_CLIENT_ID: 'Peuc12y02UA0eAED1dqSjE5HtGUrpBsx'
24+
AUTHENTICATION_OIDC_ISSUER: 'https://auth.weaviate.cloud/Peuc12y02UA0eAED1dqSjE5HtGUrpBsx'
2325
AUTHENTICATION_OIDC_USERNAME_CLAIM: 'email'
24-
AUTHENTICATION_OIDC_GROUPS_CLAIM: 'groups'
26+
AUTHENTICATION_OIDC_GROUPS_CLAIM: 'roles'
2527
AUTHORIZATION_ADMINLIST_ENABLED: 'true'
2628
AUTHORIZATION_ADMINLIST_USERS: 'oidc-test-user@weaviate.io'
2729
AUTHENTICATION_OIDC_SCOPES: 'openid,email'

src/connection/auth.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,7 @@ class AccessTokenAuthenticator implements OidcAuthFlow {
289289
});
290290
};
291291

292-
validateOpenidConfig = () => {
293-
if (
294-
this.openidConfig.provider.grant_types_supported === undefined ||
295-
!this.openidConfig.provider.grant_types_supported.includes('refresh_token')
296-
) {
297-
throw new Error('grant_type refresh_token not supported');
298-
}
299-
};
292+
validateOpenidConfig = () => {};
300293

301294
requestAccessToken = () => {
302295
const url = this.openidConfig.provider.token_endpoint;

src/connection/journey.test.ts

Lines changed: 65 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,38 @@ import Connection from './index.js';
99
import { WeaviateStartUpError } from '../errors.js';
1010
import 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) {

src/misc/journey.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('misc endpoints', () => {
9292
.openidConfigurationGetter()
9393
.do()
9494
.then((res: any) => {
95-
expect(res.clientId).toEqual('wcs');
95+
expect(res.clientId).toEqual('Peuc12y02UA0eAED1dqSjE5HtGUrpBsx');
9696
expect(res.href).toContain('.well-known/openid-configuration');
9797
expect(res.scopes).toEqual(['openid', 'email']);
9898
});

0 commit comments

Comments
 (0)