Skip to content

Commit 6e362a0

Browse files
committed
Replace testcontainers rbac tests with compose stack
1 parent 0bec64e commit 6e362a0

File tree

4 files changed

+49
-36
lines changed

4 files changed

+49
-36
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
WEAVIATE_125: 1.25.30
1212
WEAVIATE_126: 1.26.14
1313
WEAVIATE_127: 1.27.11
14-
WEAVIATE_128: 1.28.2
14+
WEAVIATE_128: 1.28.4
1515
WEAVIATE_129: 1.29.0-rc.0
1616

1717
jobs:

ci/compose.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ function compose_down_all {
2121
}
2222

2323
function all_weaviate_ports {
24-
echo "8078 8080 8081 8082 8083 8085 8086 8087 8088 8089 8090"
24+
echo "8078 8080 8081 8082 8083 8085 8086 8087 8088 8089 8090 8091"
2525
}

ci/docker-compose-rbac.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
version: '3.4'
3+
services:
4+
weaviate-rbac:
5+
command:
6+
- --host
7+
- 0.0.0.0
8+
- --port
9+
- '8085'
10+
- --scheme
11+
- http
12+
- --write-timeout=600s
13+
image: semitechnologies/weaviate:${WEAVIATE_VERSION}
14+
ports:
15+
- 8091:8085
16+
- 50062:50051
17+
restart: on-failure:0
18+
environment:
19+
ENABLE_MODULES: "generative-dummy,reranker-dummy"
20+
PERSISTENCE_DATA_PATH: "./data-weaviate-0"
21+
CLUSTER_IN_LOCALHOST: "true"
22+
CLUSTER_GOSSIP_BIND_PORT: "7100"
23+
CLUSTER_DATA_BIND_PORT: "7101"
24+
RAFT_BOOTSTRAP_EXPECT: "1"
25+
AUTHENTICATION_APIKEY_ENABLED: "true"
26+
AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'viewer-key,editor-key,admin-key,custom-key'
27+
AUTHENTICATION_APIKEY_USERS: 'viewer-user,editor-user,admin-user,custom-user'
28+
AUTHORIZATION_RBAC_ENABLED: "true"
29+
AUTHORIZATION_ADMIN_USERS: "admin-user"
30+
AUTHORIZATION_VIEWER_USERS: "viewer-user"
31+
...

src/roles/integration.test.ts

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { StartedWeaviateContainer, WeaviateContainer } from '@testcontainers/weaviate';
21
import weaviate, { ApiKey, Permission, Role, WeaviateClient } from '..';
3-
import { WeaviateInsufficientPermissionsError, WeaviateUnexpectedStatusCodeError } from '../errors';
2+
import {
3+
WeaviateInsufficientPermissionsError,
4+
WeaviateStartUpError,
5+
WeaviateUnexpectedStatusCodeError,
6+
} from '../errors';
47
import { DbVersion } from '../utils/dbVersion';
58

69
const only = DbVersion.fromString(`v${process.env.WEAVIATE_VERSION!}`).isAtLeast(1, 28, 0)
@@ -9,53 +12,32 @@ const only = DbVersion.fromString(`v${process.env.WEAVIATE_VERSION!}`).isAtLeast
912

1013
only('Integration testing of the roles namespace', () => {
1114
let client: WeaviateClient;
12-
let container: StartedWeaviateContainer;
1315

1416
beforeAll(async () => {
15-
container = await new WeaviateContainer(`semitechnologies/weaviate:${process.env.WEAVIATE_VERSION}`)
16-
.withExposedPorts(8080, 50051)
17-
.withEnvironment({
18-
AUTHENTICATION_APIKEY_ENABLED: 'true',
19-
AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'admin-key,custom-key',
20-
AUTHENTICATION_APIKEY_USERS: 'admin-user,custom-user',
21-
AUTHORIZATION_ADMIN_USERS: 'admin-user',
22-
AUTHORIZATION_ENABLE_RBAC: 'true',
23-
})
24-
.start();
25-
expect(container).toBeDefined();
2617
client = await weaviate.connectToLocal({
27-
host: container.getHost(),
28-
port: container.getMappedPort(8080),
29-
grpcPort: container.getMappedPort(50051),
18+
port: 8091,
19+
grpcPort: 50062,
3020
authCredentials: new ApiKey('admin-key'),
3121
});
3222
});
3323

34-
afterAll(async () => {
35-
await container.stop();
36-
});
37-
3824
it('should be able to retrieve the default roles', async () => {
3925
const roles = await client.roles.listAll();
4026
expect(Object.values(roles).length).toBeGreaterThan(0);
4127
});
4228

43-
it('should fail with insufficient permissions if no key provided', async () => {
44-
const unauthenticatedClient = await weaviate.connectToLocal({
45-
host: container.getHost(),
46-
port: container.getMappedPort(8080),
47-
grpcPort: container.getMappedPort(50051),
48-
});
49-
await expect(unauthenticatedClient.roles.listAll()).rejects.toThrowError(
50-
WeaviateInsufficientPermissionsError
51-
); // should be unauthenticated error, needs fixing on server
52-
});
29+
it('should fail to start up if no key provided', () =>
30+
expect(
31+
weaviate.connectToLocal({
32+
port: 8091,
33+
grpcPort: 50062,
34+
})
35+
).rejects.toThrowError(WeaviateStartUpError));
5336

5437
it('should fail with insufficient permissions if permission-less key provided', async () => {
5538
const unauthenticatedClient = await weaviate.connectToLocal({
56-
host: container.getHost(),
57-
port: container.getMappedPort(8080),
58-
grpcPort: container.getMappedPort(50051),
39+
port: 8091,
40+
grpcPort: 50062,
5941
authCredentials: new ApiKey('custom-key'),
6042
});
6143
await expect(unauthenticatedClient.roles.listAll()).rejects.toThrowError(

0 commit comments

Comments
 (0)