use of org.eclipse.hono.service.management.tenant.TrustedCertificateAuthority in project hono by eclipse.
the class TenantManagementIT method testUpdateTenantFailsForConfigurationWithNonUniqueTrustAnchorIds.
/**
* Verifies that the service returns a 400 status code for an update tenant request containing a malformed trust
* configuration (i.e with non-unique trust anchor IDs).
*
* @param context The Vert.x test context.
*/
@Test
public void testUpdateTenantFailsForConfigurationWithNonUniqueTrustAnchorIds(final VertxTestContext context) {
final PublicKey publicKey = TenantApiTests.getRandomPublicKey();
final TrustedCertificateAuthority trustAnchor1 = Tenants.createTrustAnchor("test-ca", "CN=test-dn", publicKey.getEncoded(), publicKey.getAlgorithm(), Instant.now(), Instant.now().plus(365, ChronoUnit.DAYS));
final TrustedCertificateAuthority trustAnchor2 = Tenants.createTrustAnchor("test-ca", "CN=test-dn", publicKey.getEncoded(), publicKey.getAlgorithm(), Instant.now().plus(366, ChronoUnit.DAYS), Instant.now().plus(730, ChronoUnit.DAYS));
final Tenant tenantForUpdate = new Tenant().setTrustedCertificateAuthorities(List.of(trustAnchor1, trustAnchor2));
final String tenantId = getHelper().getRandomTenantId();
getHelper().registry.addTenant(tenantId, new Tenant()).compose(ok -> getHelper().registry.updateTenant(tenantId, tenantForUpdate, HttpURLConnection.HTTP_BAD_REQUEST)).onComplete(context.succeeding(response -> {
context.verify(() -> IntegrationTestSupport.assertErrorPayload(response));
context.completeNow();
}));
}
use of org.eclipse.hono.service.management.tenant.TrustedCertificateAuthority in project hono by eclipse.
the class TenantManagementIT method testUpdateTenantFailsForConfigurationWithDuplicateTrustAnchor.
/**
* Verifies that the service returns a 409 status code for an update tenant request containing a
* CA that is already in use by another tenant that does not belong to the same trust anchor group.
*
* @param context The Vert.x test context.
*/
@Test
public void testUpdateTenantFailsForConfigurationWithDuplicateTrustAnchor(final VertxTestContext context) {
final PublicKey publicKey = TenantApiTests.getRandomPublicKey();
final TrustedCertificateAuthority trustAnchor = Tenants.createTrustAnchor("test-ca", "CN=test-dn", publicKey.getEncoded(), publicKey.getAlgorithm(), Instant.now(), Instant.now().plus(365, ChronoUnit.DAYS));
final Tenant tenant = new Tenant().setTrustedCertificateAuthorities(List.of(trustAnchor));
final String tenantId = getHelper().getRandomTenantId();
getHelper().registry.addTenant(getHelper().getRandomTenantId(), tenant).onFailure(context::failNow).compose(ok -> getHelper().registry.addTenant(tenantId, new Tenant())).onFailure(context::failNow).compose(ok -> getHelper().registry.updateTenant(tenantId, tenant, HttpURLConnection.HTTP_CONFLICT)).onComplete(context.succeeding(response -> {
context.verify(() -> IntegrationTestSupport.assertErrorPayload(response));
context.completeNow();
}));
}
Aggregations