Skip to content

Commit

Permalink
Ensure that device id template attribute is not propagated to TenantO…
Browse files Browse the repository at this point in the history
…bject during conversion

Signed-off-by: Kartheeswaran Kalidass <kartheeswaran.kalidass@bosch.io>
  • Loading branch information
kaniyan committed May 20, 2021
1 parent 27d841a commit 2b684a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public static JsonObject convertTenant(final String tenantId, final Tenant sourc
// remove the attributes that are internal to the device registry
// and not to be exposed to the adapters
json.remove(RegistryManagementConstants.FIELD_AUTO_PROVISION_AS_GATEWAY);
json.remove(RegistryManagementConstants.FIELD_AUTO_PROVISIONING_DEVICE_ID_TEMPLATE);
return json;
})
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,16 @@ public void testConversion() {
.setPublicKey("NOT_A_PUBLIC_KEY".getBytes())
.setNotBefore(Instant.now().minus(1, ChronoUnit.DAYS))
.setNotAfter(Instant.now().plus(2, ChronoUnit.DAYS))
.setAutoProvisioningAsGatewayEnabled(true);
.setAutoProvisioningAsGatewayEnabled(true)
.setAutoProvisioningDeviceIdTemplate("device-{{subject-dn}}");
final TrustedCertificateAuthority ca2 = new TrustedCertificateAuthority()
.setSubjectDn("CN=test.org")
.setKeyAlgorithm("RSA")
.setPublicKey("NOT_A_PUBLIC_KEY".getBytes())
.setNotBefore(Instant.now().plus(1, ChronoUnit.DAYS))
.setNotAfter(Instant.now().plus(20, ChronoUnit.DAYS))
.setAutoProvisioningAsGatewayEnabled(true);
.setAutoProvisioningAsGatewayEnabled(true)
.setAutoProvisioningDeviceIdTemplate("device-{{subject-dn}}");

final Tenant source = new Tenant();
source.setEnabled(true);
Expand Down Expand Up @@ -456,5 +458,7 @@ public void testConversion() {
//Verify that the internal attributes to the device registry are not transferred to the TenantObject
assertThat(expectedAuthorities.getJsonObject(0)
.containsKey(RegistryManagementConstants.FIELD_AUTO_PROVISION_AS_GATEWAY)).isFalse();
assertThat(expectedAuthorities.getJsonObject(0)
.containsKey(RegistryManagementConstants.FIELD_AUTO_PROVISIONING_DEVICE_ID_TEMPLATE)).isFalse();
}
}

0 comments on commit 2b684a6

Please sign in to comment.