11import weaviate , { ApiKey , Permission , Role , WeaviateClient } from '..' ;
2- import {
3- WeaviateInsufficientPermissionsError ,
4- WeaviateStartUpError ,
5- WeaviateUnexpectedStatusCodeError ,
6- } from '../errors' ;
2+ import { WeaviateStartUpError , WeaviateUnexpectedStatusCodeError } from '../errors' ;
73import { DbVersion } from '../utils/dbVersion' ;
84
95const only = DbVersion . fromString ( `v${ process . env . WEAVIATE_VERSION ! } ` ) . isAtLeast ( 1 , 29 , 0 )
@@ -34,17 +30,6 @@ only('Integration testing of the roles namespace', () => {
3430 } )
3531 ) . rejects . toThrowError ( WeaviateStartUpError ) ) ;
3632
37- it ( 'should fail with insufficient permissions if permission-less key provided' , async ( ) => {
38- const unauthenticatedClient = await weaviate . connectToLocal ( {
39- port : 8091 ,
40- grpcPort : 50062 ,
41- authCredentials : new ApiKey ( 'custom-key' ) ,
42- } ) ;
43- await expect ( unauthenticatedClient . roles . listAll ( ) ) . rejects . toThrowError (
44- WeaviateInsufficientPermissionsError
45- ) ;
46- } ) ;
47-
4833 it ( 'should check the existance of a real role' , async ( ) => {
4934 const exists = await client . roles . exists ( 'admin' ) ;
5035 expect ( exists ) . toBeTruthy ( ) ;
@@ -73,6 +58,7 @@ only('Integration testing of the roles namespace', () => {
7358 dataPermissions : [ ] ,
7459 nodesPermissions : [ ] ,
7560 rolesPermissions : [ ] ,
61+ usersPermissions : [ ] ,
7662 } ,
7763 } ,
7864 {
@@ -86,6 +72,7 @@ only('Integration testing of the roles namespace', () => {
8672 dataPermissions : [ ] ,
8773 nodesPermissions : [ ] ,
8874 rolesPermissions : [ ] ,
75+ usersPermissions : [ ] ,
8976 } ,
9077 } ,
9178 {
@@ -110,6 +97,7 @@ only('Integration testing of the roles namespace', () => {
11097 dataPermissions : [ ] ,
11198 nodesPermissions : [ ] ,
11299 rolesPermissions : [ ] ,
100+ usersPermissions : [ ] ,
113101 } ,
114102 } ,
115103 {
@@ -134,17 +122,17 @@ only('Integration testing of the roles namespace', () => {
134122 ] ,
135123 nodesPermissions : [ ] ,
136124 rolesPermissions : [ ] ,
125+ usersPermissions : [ ] ,
137126 } ,
138127 } ,
139128 {
140- roleName : 'nodes' ,
141- permissions : weaviate . permissions . nodes ( {
129+ roleName : 'nodes-verbose ' ,
130+ permissions : weaviate . permissions . nodes . verbose ( {
142131 collection : 'Some-collection' ,
143- verbosity : 'verbose' ,
144132 read : true ,
145133 } ) ,
146134 expected : {
147- name : 'nodes' ,
135+ name : 'nodes-verbose ' ,
148136 backupsPermissions : [ ] ,
149137 clusterPermissions : [ ] ,
150138 collectionsPermissions : [ ] ,
@@ -153,6 +141,23 @@ only('Integration testing of the roles namespace', () => {
153141 { collection : 'Some-collection' , verbosity : 'verbose' , actions : [ 'read_nodes' ] } ,
154142 ] ,
155143 rolesPermissions : [ ] ,
144+ usersPermissions : [ ] ,
145+ } ,
146+ } ,
147+ {
148+ roleName : 'nodes-minimal' ,
149+ permissions : weaviate . permissions . nodes . minimal ( {
150+ read : true ,
151+ } ) ,
152+ expected : {
153+ name : 'nodes-minimal' ,
154+ backupsPermissions : [ ] ,
155+ clusterPermissions : [ ] ,
156+ collectionsPermissions : [ ] ,
157+ dataPermissions : [ ] ,
158+ nodesPermissions : [ { collection : '*' , verbosity : 'minimal' , actions : [ 'read_nodes' ] } ] ,
159+ rolesPermissions : [ ] ,
160+ usersPermissions : [ ] ,
156161 } ,
157162 } ,
158163 {
@@ -174,6 +179,25 @@ only('Integration testing of the roles namespace', () => {
174179 rolesPermissions : [
175180 { role : 'some-role' , actions : [ 'create_roles' , 'read_roles' , 'update_roles' , 'delete_roles' ] } ,
176181 ] ,
182+ usersPermissions : [ ] ,
183+ } ,
184+ } ,
185+ {
186+ roleName : 'users' ,
187+ permissions : weaviate . permissions . users ( {
188+ user : 'some-user' ,
189+ assign_and_revoke : true ,
190+ read : true ,
191+ } ) ,
192+ expected : {
193+ name : 'users' ,
194+ backupsPermissions : [ ] ,
195+ clusterPermissions : [ ] ,
196+ collectionsPermissions : [ ] ,
197+ dataPermissions : [ ] ,
198+ nodesPermissions : [ ] ,
199+ rolesPermissions : [ ] ,
200+ usersPermissions : [ { users : 'some-user' , actions : [ 'assign_and_revoke_users' , 'read_users' ] } ] ,
177201 } ,
178202 } ,
179203 ] ;
@@ -194,7 +218,9 @@ only('Integration testing of the roles namespace', () => {
194218
195219 afterAll ( ( ) =>
196220 Promise . all (
197- [ 'backups' , 'cluster' , 'collections' , 'data' , 'nodes' , 'roles' ] . map ( ( n ) => client . roles . delete ( n ) )
221+ [ 'backups' , 'cluster' , 'collections' , 'data' , 'nodes-verbose' , 'nodes-minimal' , 'roles' , 'users' ] . map (
222+ ( n ) => client . roles . delete ( n )
223+ )
198224 )
199225 ) ;
200226} ) ;
0 commit comments