Search in sources :

Example 1 with RequiresCloudantService

use of com.cloudant.test.main.RequiresCloudantService in project java-cloudant by cloudant.

the class CloudantClientTests method apiKey.

@Test
@RequiresCloudantService
public void apiKey() {
    ApiKey key = account.generateApiKey();
    assertNotNull(key);
    assertNotNull(key.getKey());
    assertNotNull(key.getPassword());
}
Also used : ApiKey(com.cloudant.client.api.model.ApiKey) Test(org.junit.jupiter.api.Test) RequiresCloudantService(com.cloudant.test.main.RequiresCloudantService)

Example 2 with RequiresCloudantService

use of com.cloudant.test.main.RequiresCloudantService in project java-cloudant by cloudant.

the class SslAuthenticationTest method remoteSslAuthenticationEnabledTest.

/**
 * Connect to the remote Cloudant server with SSL Authentication enabled.
 * This shouldn't throw an exception as the Cloudant server has a valid
 * SSL certificate, so should be authenticated.
 */
@TestTemplate
@RequiresCloudantService
public void remoteSslAuthenticationEnabledTest() {
    CloudantClient dbClient = CloudantClientHelper.getClientBuilder().build();
    // Make an arbitrary connection to the DB.
    dbClient.getAllDbs();
// Test is successful if no exception is thrown, so no explicit check is needed.
}
Also used : CloudantClient(com.cloudant.client.api.CloudantClient) TestTemplate(org.junit.jupiter.api.TestTemplate) RequiresCloudantService(com.cloudant.test.main.RequiresCloudantService)

Example 3 with RequiresCloudantService

use of com.cloudant.test.main.RequiresCloudantService in project java-cloudant by cloudant.

the class SslAuthenticationTest method remoteSslAuthenticationDisabledTest.

/**
 * Connect to the remote Cloudant server with SSL Authentication disabled.
 */
@TestTemplate
@RequiresCloudantService
public void remoteSslAuthenticationDisabledTest() {
    CloudantClient dbClient = CloudantClientHelper.getClientBuilder().disableSSLAuthentication().build();
    // Make an arbitrary connection to the DB.
    dbClient.getAllDbs();
// Test is successful if no exception is thrown, so no explicit check is needed.
}
Also used : CloudantClient(com.cloudant.client.api.CloudantClient) TestTemplate(org.junit.jupiter.api.TestTemplate) RequiresCloudantService(com.cloudant.test.main.RequiresCloudantService)

Example 4 with RequiresCloudantService

use of com.cloudant.test.main.RequiresCloudantService in project java-cloudant by cloudant.

the class DatabaseTest method permissions.

@Test
@RequiresCloudantService
public void permissions() {
    Map<String, EnumSet<Permissions>> userPerms = db.getPermissions();
    assertNotNull(userPerms);
    ApiKey key = account.generateApiKey();
    EnumSet<Permissions> p = EnumSet.<Permissions>of(Permissions._reader, Permissions._writer);
    db.setPermissions(key.getKey(), p);
    userPerms = db.getPermissions();
    assertNotNull(userPerms);
    assertEquals(1, userPerms.size());
    assertEquals(p, userPerms.get(key.getKey()));
    p = EnumSet.noneOf(Permissions.class);
    db.setPermissions(key.getKey(), p);
    userPerms = db.getPermissions();
    assertNotNull(userPerms);
    assertEquals(1, userPerms.size());
    assertEquals(p, userPerms.get(key.getKey()));
}
Also used : ApiKey(com.cloudant.client.api.model.ApiKey) EnumSet(java.util.EnumSet) Permissions(com.cloudant.client.api.model.Permissions) Test(org.junit.jupiter.api.Test) RequiresCloudantService(com.cloudant.test.main.RequiresCloudantService)

Aggregations

RequiresCloudantService (com.cloudant.test.main.RequiresCloudantService)4 CloudantClient (com.cloudant.client.api.CloudantClient)2 ApiKey (com.cloudant.client.api.model.ApiKey)2 Test (org.junit.jupiter.api.Test)2 TestTemplate (org.junit.jupiter.api.TestTemplate)2 Permissions (com.cloudant.client.api.model.Permissions)1 EnumSet (java.util.EnumSet)1