use of org.opensmartgridplatform.secretmanagement.application.domain.SecretType in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method theEncryptedSecretTableInTheSecretManagementDatabaseShouldContainKeysForDevice.
@Then("the encrypted_secret table in the secret management database should contain {string} keys for device {string}")
public void theEncryptedSecretTableInTheSecretManagementDatabaseShouldContainKeysForDevice(final String secretTypeString, final String deviceIdentification, final Map<String, String> inputSettings) {
final SecretType secretType = this.getSecretTypeByKeyTypeInputName(secretTypeString);
for (final String keyName : inputSettings.keySet()) {
final String secretStatus = inputSettings.get(keyName);
final String dbEncryptedSecretValue = SecurityKey.valueOf(keyName).getDatabaseKey();
final List<DbEncryptedSecret> dbEncryptedSecret = this.encryptedSecretRepository.findSecrets(deviceIdentification, secretType, SecretStatus.valueOf(secretStatus));
assertThat(dbEncryptedSecret).withFailMessage("No dbEncryptedSecret for %s with status %s found", secretTypeString, secretStatus).isNotEmpty();
final List<String> actualEncodedSecrets = dbEncryptedSecret.stream().map(DbEncryptedSecret::getEncodedSecret).collect(Collectors.toList());
assertThat(actualEncodedSecrets).withFailMessage("Wrong dbEncryptedSecret for %s with status %s expected %s to be contained in: %s", secretTypeString, secretStatus, dbEncryptedSecretValue, actualEncodedSecrets).contains(dbEncryptedSecretValue);
}
}
Aggregations