use of org.infinispan.client.rest.RestClusterClient in project infinispan by infinispan.
the class BackupManagerIT method testClusterBackupFromFile.
@Test
public void testClusterBackupFromFile() throws Exception {
String name = "testClusterBackup";
performTest(client -> {
RestClusterClient cluster = client.cluster();
RestResponse response = await(cluster.createBackup(name));
assertEquals(202, response.getStatus());
return awaitOk(() -> cluster.getBackup(name, false));
}, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
RestClusterClient c = client.cluster();
RestResponse response = await(c.restore(name, zip.getPath()));
assertEquals(202, response.getStatus());
return awaitCreated(() -> c.getRestore(name));
}, this::assertWildcardContent, true);
}
use of org.infinispan.client.rest.RestClusterClient in project infinispan by infinispan.
the class BackupManagerIT method testClusterBackupUpload.
@Test
public void testClusterBackupUpload() throws Exception {
String name = "testClusterBackup";
performTest(client -> {
RestClusterClient cluster = client.cluster();
RestResponse response = await(cluster.createBackup(name));
assertEquals(202, response.getStatus());
return awaitOk(() -> cluster.getBackup(name, false));
}, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
RestClusterClient c = client.cluster();
RestResponse response = await(c.restore(name, zip));
assertEquals(202, response.getStatus());
return awaitCreated(() -> c.getRestore(name));
}, this::assertWildcardContent, false);
}
use of org.infinispan.client.rest.RestClusterClient in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotAccessBackupsAndRestores.
@Test
public void testRestNonAdminsMustNotAccessBackupsAndRestores() {
for (TestUser user : TestUser.NON_ADMINS) {
RestClusterClient client = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get().cluster();
assertStatus(FORBIDDEN, client.createBackup("backup"));
assertStatus(FORBIDDEN, client.getBackup("backup", true));
assertStatus(FORBIDDEN, client.getBackupNames());
assertStatus(FORBIDDEN, client.deleteBackup("backup"));
assertStatus(FORBIDDEN, client.restore("restore", "somewhere"));
assertStatus(FORBIDDEN, client.getRestoreNames());
assertStatus(FORBIDDEN, client.getRestore("restore"));
assertStatus(FORBIDDEN, client.deleteRestore("restore"));
}
}
use of org.infinispan.client.rest.RestClusterClient in project infinispan by infinispan.
the class AbstractAuthorization method testRestAdminsMustAccessBackupsAndRestores.
@Test
public void testRestAdminsMustAccessBackupsAndRestores() throws IOException {
String BACKUP_NAME = "backup";
RestClusterClient client = getServerTest().rest().withClientConfiguration(restBuilders.get(TestUser.ADMIN)).get().cluster();
assertStatus(ACCEPTED, client.createBackup(BACKUP_NAME));
RestResponse response = awaitStatus(() -> client.getBackup(BACKUP_NAME, false), ACCEPTED, OK);
String fileName = response.getHeader("Content-Disposition").split("=")[1];
File backupZip = new File(getServers().getServerDriver().getRootDir(), fileName);
try (InputStream is = response.getBodyAsStream()) {
Files.copy(is, backupZip.toPath(), StandardCopyOption.REPLACE_EXISTING);
} finally {
response.close();
}
assertStatus(NO_CONTENT, client.deleteBackup(BACKUP_NAME));
assertStatus(OK, client.getBackupNames());
assertStatus(ACCEPTED, client.restore(BACKUP_NAME, backupZip));
assertStatus(OK, client.getRestoreNames());
awaitStatus(() -> client.getRestore(BACKUP_NAME), ACCEPTED, CREATED);
assertStatus(NO_CONTENT, client.deleteRestore(BACKUP_NAME));
}
Aggregations