Search in sources :

Example 16 with AccountTelemetry

use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.

the class AccountTelemetryServiceTest method testDefaultRules.

@Test
public void testDefaultRules() {
    // GIVEN
    // WHEN
    AccountTelemetry result = underTest.createDefaultAccuontTelemetry();
    // THEN
    for (AnonymizationRule rule : result.getRules()) {
        testPatternWithOutput(rule, "str myemail@email.com", "email");
        testPatternWithOutput(rule, "333-44-2222", "XXX-");
        testPatternWithOutput(rule, "card number: 1111-2222-3333-4444", "XXXX-");
        testPatternWithOutput(rule, "- FPW: secret", "FPW");
        testPatternWithOutput(rule, "cdpHashedPassword='{SHA512}abcdef'", "[CDP");
    }
    assertThat(result.getFeatures().getClusterLogsCollection().isEnabled()).isEqualTo(false);
}
Also used : AnonymizationRule(com.sequenceiq.common.api.telemetry.model.AnonymizationRule) AccountTelemetry(com.sequenceiq.environment.telemetry.domain.AccountTelemetry) Test(org.junit.jupiter.api.Test)

Example 17 with AccountTelemetry

use of com.sequenceiq.environment.telemetry.domain.AccountTelemetry in project cloudbreak by hortonworks.

the class AccountTelemetryServiceTest method testValidateRulesWithInvalidRules.

@Test
public void testValidateRulesWithInvalidRules() {
    // GIVEN
    AccountTelemetry telemetry = new AccountTelemetry();
    List<AnonymizationRule> rules = new ArrayList<>();
    AnonymizationRule rule = new AnonymizationRule();
    rule.setReplacement("[REDACTED]");
    String pattern = "invalidrule{";
    String encodedPattern = new String(Base64.getEncoder().encode(pattern.getBytes()));
    rule.setValue(encodedPattern);
    rules.add(rule);
    telemetry.setRules(rules);
    // THEN
    assertThrows(BadRequestException.class, () -> {
        // WHEN
        underTest.validateAnonymizationRules(telemetry);
    });
}
Also used : AnonymizationRule(com.sequenceiq.common.api.telemetry.model.AnonymizationRule) AccountTelemetry(com.sequenceiq.environment.telemetry.domain.AccountTelemetry) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)17 Test (org.junit.jupiter.api.Test)11 Features (com.sequenceiq.common.api.telemetry.model.Features)10 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)8 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)8 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 FreeIpaCreationDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationDto)7 AnonymizationRule (com.sequenceiq.common.api.telemetry.model.AnonymizationRule)4 EnvironmentBackup (com.sequenceiq.environment.environment.dto.EnvironmentBackup)4 ArrayList (java.util.ArrayList)3 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)3 AccessDeniedException (org.springframework.security.access.AccessDeniedException)3 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)1 CrnResourceDescriptor (com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor)1 RegionAwareCrnGenerator (com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 EnvironmentEditRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest)1