1
- import { StartedWeaviateContainer , WeaviateContainer } from '@testcontainers/weaviate' ;
2
1
import weaviate , { ApiKey , Permission , Role , WeaviateClient } from '..' ;
3
- import { WeaviateInsufficientPermissionsError , WeaviateUnexpectedStatusCodeError } from '../errors' ;
2
+ import {
3
+ WeaviateInsufficientPermissionsError ,
4
+ WeaviateStartUpError ,
5
+ WeaviateUnexpectedStatusCodeError ,
6
+ } from '../errors' ;
4
7
import { DbVersion } from '../utils/dbVersion' ;
5
8
6
9
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
9
12
10
13
only ( 'Integration testing of the roles namespace' , ( ) => {
11
14
let client : WeaviateClient ;
12
- let container : StartedWeaviateContainer ;
13
15
14
16
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 ( ) ;
26
17
client = await weaviate . connectToLocal ( {
27
- host : container . getHost ( ) ,
28
- port : container . getMappedPort ( 8080 ) ,
29
- grpcPort : container . getMappedPort ( 50051 ) ,
18
+ port : 8091 ,
19
+ grpcPort : 50062 ,
30
20
authCredentials : new ApiKey ( 'admin-key' ) ,
31
21
} ) ;
32
22
} ) ;
33
23
34
- afterAll ( async ( ) => {
35
- await container . stop ( ) ;
36
- } ) ;
37
-
38
24
it ( 'should be able to retrieve the default roles' , async ( ) => {
39
25
const roles = await client . roles . listAll ( ) ;
40
26
expect ( Object . values ( roles ) . length ) . toBeGreaterThan ( 0 ) ;
41
27
} ) ;
42
28
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 ) ) ;
53
36
54
37
it ( 'should fail with insufficient permissions if permission-less key provided' , async ( ) => {
55
38
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 ,
59
41
authCredentials : new ApiKey ( 'custom-key' ) ,
60
42
} ) ;
61
43
await expect ( unauthenticatedClient . roles . listAll ( ) ) . rejects . toThrowError (
0 commit comments