Search in sources :

Example 11 with SecretType

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);
    }
}
Also used : SecretType(org.opensmartgridplatform.secretmanagement.application.domain.SecretType) DbEncryptedSecret(org.opensmartgridplatform.secretmanagement.application.domain.DbEncryptedSecret) Then(io.cucumber.java.en.Then)

Aggregations

SecretType (org.opensmartgridplatform.secretmanagement.application.domain.SecretType)11 DbEncryptedSecret (org.opensmartgridplatform.secretmanagement.application.domain.DbEncryptedSecret)5 Date (java.util.Date)4 DbEncryptionKeyReference (org.opensmartgridplatform.secretmanagement.application.domain.DbEncryptionKeyReference)4 TypedSecret (org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)4 SecretTypes (org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes)3 Test (org.junit.jupiter.api.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 SecretBuilder (org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.SecretBuilder)2 TypedSecrets (org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets)2 Given (io.cucumber.java.en.Given)1 Then (io.cucumber.java.en.Then)1 GenerateAndStoreSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse)1 GetNewSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GetNewSecretsResponse)1 GetSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GetSecretsResponse)1 HasNewSecretResponse (org.opensmartgridplatform.ws.schema.core.secret.management.HasNewSecretResponse)1