@@ -32,6 +32,10 @@ describe('Tables API', function () {
3232 TestObjects . team = app . team
3333 TestObjects . application = app . application
3434 TestObjects . instance = app . instance
35+ TestObjects . device = await app . factory . createDevice ( {
36+ name : 'device1' ,
37+ mode : 'developer'
38+ } , app . team , app . instance )
3539
3640 TestObjects . alice = await app . db . models . User . byUsername ( 'alice' )
3741 await login ( 'alice' , 'aaPassword' )
@@ -121,6 +125,38 @@ describe('Tables API', function () {
121125 dbs [ 0 ] . should . have . property ( 'name' , TestObjects . team . hashid )
122126 } )
123127
128+ it ( 'Get Team database list as Instance' , async function ( ) {
129+ const projectTokens = await app . instance . refreshAuthTokens ( )
130+ const response = await app . inject ( {
131+ method : 'GET' ,
132+ url : `/api/v1/teams/${ TestObjects . team . hashid } /databases` ,
133+ headers : {
134+ Authorization : `Bearer ${ projectTokens . token } `
135+ }
136+ } )
137+ response . statusCode . should . equal ( 200 )
138+ const dbs = response . json ( )
139+ dbs . should . be . an . Array ( ) . and . have . length ( 1 )
140+ dbs [ 0 ] . should . have . property ( 'id' )
141+ dbs [ 0 ] . should . have . property ( 'name' , TestObjects . team . hashid )
142+ } )
143+
144+ it ( 'Get Team database list as Device' , async function ( ) {
145+ const deviceToken = await app . db . controllers . AccessToken . createTokenForDevice ( TestObjects . device )
146+ const response = await app . inject ( {
147+ method : 'GET' ,
148+ url : `/api/v1/teams/${ TestObjects . team . hashid } /databases` ,
149+ headers : {
150+ Authorization : `Bearer ${ deviceToken . token } `
151+ }
152+ } )
153+ response . statusCode . should . equal ( 200 )
154+ const dbs = response . json ( )
155+ dbs . should . be . an . Array ( ) . and . have . length ( 1 )
156+ dbs [ 0 ] . should . have . property ( 'id' )
157+ dbs [ 0 ] . should . have . property ( 'name' , TestObjects . team . hashid )
158+ } )
159+
124160 it ( 'Get Team database by ID' , async function ( ) {
125161 const db = ( await app . db . models . Table . byTeamId ( TestObjects . team . id ) ) [ 0 ]
126162 const response = await app . inject ( {
0 commit comments