Skip to content

Commit ba8a234

Browse files
author
Mark
committed
getAccessibleDatabasesFor user
1 parent ffc4295 commit ba8a234

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

src/main/java/com/arangodb/ArangoDBAsync.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public ArangoDatabaseAsync db(final String name) {
243243
}
244244

245245
/**
246-
* creates a new database
246+
* Creates a new database
247247
*
248248
* @see <a href="https://docs.arangodb.com/current/HTTP/Database/DatabaseManagement.html#create-database">API
249249
* Documentation</a>
@@ -256,6 +256,8 @@ public CompletableFuture<Boolean> createDatabase(final String name) {
256256
}
257257

258258
/**
259+
* Retrieves a list of all existing databases
260+
*
259261
* @see <a href="https://docs.arangodb.com/current/HTTP/Database/DatabaseManagement.html#list-of-databases">API
260262
* Documentation</a>
261263
* @return a list of all existing databases
@@ -265,6 +267,8 @@ public CompletableFuture<Collection<String>> getDatabases() {
265267
}
266268

267269
/**
270+
* Retrieves a list of all databases the current user can access
271+
*
268272
* @see <a href=
269273
* "https://docs.arangodb.com/current/HTTP/Database/DatabaseManagement.html#list-of-accessible-databases">API
270274
* Documentation</a>
@@ -274,6 +278,22 @@ public CompletableFuture<Collection<String>> getAccessibleDatabases() {
274278
return executor.execute(getAccessibleDatabasesRequest(db().name()), getDatabaseResponseDeserializer());
275279
}
276280

281+
/**
282+
* List available database to the specified user
283+
*
284+
* @see <a href=
285+
* "https://docs.arangodb.com/current/HTTP/UserManagement/index.html#list-the-databases-available-to-a-user">API
286+
* Documentation</a>
287+
* @param user
288+
* The name of the user for which you want to query the databases
289+
* @return
290+
* @throws ArangoDBException
291+
*/
292+
public CompletableFuture<Collection<String>> getAccessibleDatabasesFor(final String user) {
293+
return executor.execute(getAccessibleDatabasesForRequest(db().name(), user),
294+
getAccessibleDatabasesForResponseDeserializer());
295+
}
296+
277297
/**
278298
* Returns the server name and version number.
279299
*

src/test/java/com/arangodb/ArangoDBTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
package com.arangodb;
2222

23-
import static org.hamcrest.CoreMatchers.notNullValue;
2423
import static org.hamcrest.Matchers.anyOf;
2524
import static org.hamcrest.Matchers.contains;
2625
import static org.hamcrest.Matchers.empty;
@@ -29,6 +28,7 @@
2928
import static org.hamcrest.Matchers.hasItem;
3029
import static org.hamcrest.Matchers.is;
3130
import static org.hamcrest.Matchers.not;
31+
import static org.hamcrest.Matchers.notNullValue;
3232
import static org.junit.Assert.assertThat;
3333
import static org.junit.Assert.fail;
3434

@@ -136,6 +136,20 @@ public void getAccessibleDatabases() throws InterruptedException, ExecutionExcep
136136
f.get();
137137
}
138138

139+
@Test
140+
public void getAccessibleDatabasesFor() throws InterruptedException, ExecutionException {
141+
final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build();
142+
final CompletableFuture<Collection<String>> f = arangoDB.getAccessibleDatabasesFor("root");
143+
assertThat(f, is(notNullValue()));
144+
f.whenComplete((dbs, ex) -> {
145+
assertThat(dbs, is(notNullValue()));
146+
assertThat(dbs, is(notNullValue()));
147+
assertThat(dbs.size(), greaterThan(0));
148+
assertThat(dbs, hasItem("_system"));
149+
});
150+
f.get();
151+
}
152+
139153
@Test
140154
public void createUser() throws InterruptedException, ExecutionException {
141155
final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build();

tests/travis/setup_arangodb.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ echo "Starting ArangoDB '${ARANGOD}'"
2929
${ARANGOD} \
3030
--database.directory ${TMP_DIR} \
3131
--configuration none \
32-
--server.endpoint vpp+tcp://127.0.0.1:8529 \
33-
--server.endpoint vpp+ssl://127.0.0.1:8530 \
34-
--server.endpoint tcp://127.0.0.1:8531 \
32+
--server.endpoint tcp://127.0.0.1:8529 \
33+
--server.endpoint ssl://127.0.0.1:8530 \
3534
--ssl.keyfile ./server.pem \
3635
--javascript.app-path ${ARANGODB_DIR}/js/apps \
3736
--javascript.startup-directory ${ARANGODB_DIR}/js \

0 commit comments

Comments
 (0)