Skip to content

Commit 60be3b9

Browse files
committed
test: extend integration test suite
1 parent 0dfd7ae commit 60be3b9

File tree

10 files changed

+281
-159
lines changed

10 files changed

+281
-159
lines changed

.github/workflows/main.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
concurrency:
1919
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2020
cancel-in-progress: true
21-
21+
2222
jobs:
2323
checks:
2424
runs-on: ubuntu-latest
@@ -139,4 +139,4 @@ jobs:
139139
uses: softprops/action-gh-release@v1
140140
with:
141141
generate_release_notes: true
142-
draft: true
142+
draft: true

ci/compose.sh

100644100755
File mode changed.

ci/docker-compose-rbac.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ services:
2828
AUTHORIZATION_RBAC_ENABLED: "true"
2929
AUTHORIZATION_ADMIN_USERS: "admin-user"
3030
AUTHORIZATION_VIEWER_USERS: "viewer-user"
31+
AUTHENTICATION_DB_USERS_ENABLED: "true"
32+
AUTHENTICATION_OIDC_ENABLED: "true"
33+
AUTHENTICATION_OIDC_CLIENT_ID: "wcs"
34+
AUTHENTICATION_OIDC_ISSUER: "https://auth.wcs.api.weaviate.io/auth/realms/SeMI"
35+
AUTHENTICATION_OIDC_USERNAME_CLAIM: "email"
36+
AUTHENTICATION_OIDC_GROUPS_CLAIM: "groups"
3137
...

src/classifications/scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class ClassificationsScheduler extends CommandBase {
101101
reject(
102102
new Error(
103103
"classification didn't finish within configured timeout, " +
104-
'set larger timeout with .withWaitTimeout(timeout)'
104+
'set larger timeout with .withWaitTimeout(timeout)'
105105
)
106106
);
107107
}, this.waitTimeout);

src/connection/http.ts

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ export default class ConnectionREST {
115115

116116
postReturn = <B, T>(path: string, payload: B): Promise<T> => {
117117
if (this.authEnabled) {
118-
return this.login().then((token) =>
119-
this.http.post<B, T>(path, payload, true, token) as T
120-
);
118+
return this.login().then((token) => this.http.post<B, T>(path, payload, true, token) as T);
121119
}
122120
return this.http.post<B, T>(path, payload, true, '') as Promise<T>;
123121
};
@@ -376,46 +374,46 @@ const makeUrl = (basePath: string) => (path: string) => basePath + path;
376374

377375
const checkStatus =
378376
<T>(expectResponseBody: boolean) =>
379-
(res: Response) => {
380-
if (res.status >= 400) {
381-
return res.text().then((errText: string) => {
382-
let err: string;
383-
try {
384-
// in case of invalid json response (like empty string)
385-
err = JSON.stringify(JSON.parse(errText));
386-
} catch (e) {
387-
err = errText;
388-
}
389-
if (res.status === 401) {
390-
return Promise.reject(new WeaviateUnauthenticatedError(err));
391-
} else if (res.status === 403) {
392-
return Promise.reject(new WeaviateInsufficientPermissionsError(403, err));
393-
} else {
394-
return Promise.reject(new WeaviateUnexpectedStatusCodeError(res.status, err));
395-
}
396-
});
397-
}
398-
if (expectResponseBody) {
399-
return res.json() as Promise<T>;
400-
}
401-
return Promise.resolve(undefined);
402-
};
377+
(res: Response) => {
378+
if (res.status >= 400) {
379+
return res.text().then((errText: string) => {
380+
let err: string;
381+
try {
382+
// in case of invalid json response (like empty string)
383+
err = JSON.stringify(JSON.parse(errText));
384+
} catch (e) {
385+
err = errText;
386+
}
387+
if (res.status === 401) {
388+
return Promise.reject(new WeaviateUnauthenticatedError(err));
389+
} else if (res.status === 403) {
390+
return Promise.reject(new WeaviateInsufficientPermissionsError(403, err));
391+
} else {
392+
return Promise.reject(new WeaviateUnexpectedStatusCodeError(res.status, err));
393+
}
394+
});
395+
}
396+
if (expectResponseBody) {
397+
return res.json() as Promise<T>;
398+
}
399+
return Promise.resolve(undefined);
400+
};
403401

404402
const handleHeadResponse =
405403
<T>(expectResponseBody: boolean) =>
406-
(res: Response) => {
407-
if (res.status == 200 || res.status == 204 || res.status == 404) {
408-
return Promise.resolve(res.status == 200 || res.status == 204);
409-
}
410-
return checkStatus<T>(expectResponseBody)(res);
411-
};
404+
(res: Response) => {
405+
if (res.status == 200 || res.status == 204 || res.status == 404) {
406+
return Promise.resolve(res.status == 200 || res.status == 204);
407+
}
408+
return checkStatus<T>(expectResponseBody)(res);
409+
};
412410

413411
const getAuthHeaders = (config: InternalConnectionParams, bearerToken: string) =>
414412
bearerToken
415413
? {
416-
Authorization: `Bearer ${bearerToken}`,
417-
'X-Weaviate-Cluster-Url': config.host,
418-
// keeping for backwards compatibility for older clusters for now. On newer clusters, Embedding Service reuses Authorization header.
419-
'X-Weaviate-Api-Key': bearerToken,
420-
}
414+
Authorization: `Bearer ${bearerToken}`,
415+
'X-Weaviate-Cluster-Url': config.host,
416+
// keeping for backwards compatibility for older clusters for now. On newer clusters, Embedding Service reuses Authorization header.
417+
'X-Weaviate-Api-Key': bearerToken,
418+
}
421419
: undefined;

src/openapi/schema.ts

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -386,30 +386,30 @@ export interface definitions {
386386
* @enum {string}
387387
*/
388388
action:
389-
| 'manage_backups'
390-
| 'read_cluster'
391-
| 'create_data'
392-
| 'read_data'
393-
| 'update_data'
394-
| 'delete_data'
395-
| 'read_nodes'
396-
| 'create_roles'
397-
| 'read_roles'
398-
| 'update_roles'
399-
| 'delete_roles'
400-
| 'create_collections'
401-
| 'read_collections'
402-
| 'update_collections'
403-
| 'delete_collections'
404-
| 'assign_and_revoke_users'
405-
| 'create_users'
406-
| 'read_users'
407-
| 'update_users'
408-
| 'delete_users'
409-
| 'create_tenants'
410-
| 'read_tenants'
411-
| 'update_tenants'
412-
| 'delete_tenants';
389+
| 'manage_backups'
390+
| 'read_cluster'
391+
| 'create_data'
392+
| 'read_data'
393+
| 'update_data'
394+
| 'delete_data'
395+
| 'read_nodes'
396+
| 'create_roles'
397+
| 'read_roles'
398+
| 'update_roles'
399+
| 'delete_roles'
400+
| 'create_collections'
401+
| 'read_collections'
402+
| 'update_collections'
403+
| 'delete_collections'
404+
| 'assign_and_revoke_users'
405+
| 'create_users'
406+
| 'read_users'
407+
| 'update_users'
408+
| 'delete_users'
409+
| 'create_tenants'
410+
| 'read_tenants'
411+
| 'update_tenants'
412+
| 'delete_tenants';
413413
};
414414
/** @description list of roles */
415415
RolesListResponse: definitions['Role'][];
@@ -787,15 +787,15 @@ export interface definitions {
787787
* @enum {string}
788788
*/
789789
tokenization?:
790-
| 'word'
791-
| 'lowercase'
792-
| 'whitespace'
793-
| 'field'
794-
| 'trigram'
795-
| 'gse'
796-
| 'kagome_kr'
797-
| 'kagome_ja'
798-
| 'gse_ch';
790+
| 'word'
791+
| 'lowercase'
792+
| 'whitespace'
793+
| 'field'
794+
| 'trigram'
795+
| 'gse'
796+
| 'kagome_kr'
797+
| 'kagome_ja'
798+
| 'gse_ch';
799799
/** @description The properties of the nested object(s). Applies to object and object[] data types. */
800800
nestedProperties?: definitions['NestedProperty'][];
801801
};
@@ -816,15 +816,15 @@ export interface definitions {
816816
indexRangeFilters?: boolean;
817817
/** @enum {string} */
818818
tokenization?:
819-
| 'word'
820-
| 'lowercase'
821-
| 'whitespace'
822-
| 'field'
823-
| 'trigram'
824-
| 'gse'
825-
| 'kagome_kr'
826-
| 'kagome_ja'
827-
| 'gse_ch';
819+
| 'word'
820+
| 'lowercase'
821+
| 'whitespace'
822+
| 'field'
823+
| 'trigram'
824+
| 'gse'
825+
| 'kagome_kr'
826+
| 'kagome_ja'
827+
| 'gse_ch';
828828
/** @description The properties of the nested object(s). Applies to object and object[] data types. */
829829
nestedProperties?: definitions['NestedProperty'][];
830830
};
@@ -1505,19 +1505,19 @@ export interface definitions {
15051505
* @enum {string}
15061506
*/
15071507
operator?:
1508-
| 'And'
1509-
| 'Or'
1510-
| 'Equal'
1511-
| 'Like'
1512-
| 'NotEqual'
1513-
| 'GreaterThan'
1514-
| 'GreaterThanEqual'
1515-
| 'LessThan'
1516-
| 'LessThanEqual'
1517-
| 'WithinGeoRange'
1518-
| 'IsNull'
1519-
| 'ContainsAny'
1520-
| 'ContainsAll';
1508+
| 'And'
1509+
| 'Or'
1510+
| 'Equal'
1511+
| 'Like'
1512+
| 'NotEqual'
1513+
| 'GreaterThan'
1514+
| 'GreaterThanEqual'
1515+
| 'LessThan'
1516+
| 'LessThanEqual'
1517+
| 'WithinGeoRange'
1518+
| 'IsNull'
1519+
| 'ContainsAny'
1520+
| 'ContainsAll';
15211521
/**
15221522
* @description path to the property currently being filtered
15231523
* @example [
@@ -1618,16 +1618,16 @@ export interface definitions {
16181618
* @enum {string}
16191619
*/
16201620
activityStatus?:
1621-
| 'ACTIVE'
1622-
| 'INACTIVE'
1623-
| 'OFFLOADED'
1624-
| 'OFFLOADING'
1625-
| 'ONLOADING'
1626-
| 'HOT'
1627-
| 'COLD'
1628-
| 'FROZEN'
1629-
| 'FREEZING'
1630-
| 'UNFREEZING';
1621+
| 'ACTIVE'
1622+
| 'INACTIVE'
1623+
| 'OFFLOADED'
1624+
| 'OFFLOADING'
1625+
| 'ONLOADING'
1626+
| 'HOT'
1627+
| 'COLD'
1628+
| 'FROZEN'
1629+
| 'FREEZING'
1630+
| 'UNFREEZING';
16311631
};
16321632
/** @description attributes representing a single tenant response within weaviate */
16331633
TenantResponse: definitions['Tenant'] & {
@@ -4187,4 +4187,4 @@ export interface operations {
41874187
};
41884188
}
41894189

4190-
export interface external { }
4190+
export interface external {}

src/roles/util.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { WeaviateDBUser, Permission as WeaviatePermission, Role as WeaviateRole, WeaviateUser } from '../openapi/types.js';
1+
import {
2+
WeaviateDBUser,
3+
Permission as WeaviatePermission,
4+
Role as WeaviateRole,
5+
WeaviateUser,
6+
} from '../openapi/types.js';
27
import { User, UserDB } from '../users/types.js';
38
import {
49
BackupsAction,
@@ -136,19 +141,18 @@ export class Map {
136141
static user = (user: WeaviateUser): User => ({
137142
id: user.username,
138143
roles: user.roles?.map(Map.roleFromWeaviate),
139-
})
144+
});
140145
static dbUser = (user: WeaviateDBUser): UserDB => ({
141146
userType: user.dbUserType,
142147
id: user.userId,
143148
roleNames: user.roles,
144149
active: user.active,
145-
})
150+
});
146151
static dbUsers = (users: WeaviateDBUser[]): UserDB[] =>
147152
users.reduce((acc, user) => {
148153
acc.push(Map.dbUser(user));
149154
return acc;
150-
}, [] as UserDB[])
151-
;
155+
}, [] as UserDB[]);
152156
}
153157

154158
class PermissionsMapping {
@@ -172,7 +176,11 @@ class PermissionsMapping {
172176
public static use = (role: WeaviateRole) => new PermissionsMapping(role);
173177

174178
public map = (): Role => {
175-
this.role.permissions.forEach(this.permissionFromWeaviate);
179+
// If truncated roles are requested (?includeFullRoles=false),
180+
// role.permissions are not present.
181+
if (this.role.permissions !== null) {
182+
this.role.permissions.forEach(this.permissionFromWeaviate);
183+
}
176184
return {
177185
name: this.role.name,
178186
backupsPermissions: Object.values(this.mappings.backups),

0 commit comments

Comments
 (0)