Search in sources :

Example 11 with AnonymizationRule

use of com.sequenceiq.common.api.telemetry.model.AnonymizationRule 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

AnonymizationRule (com.sequenceiq.common.api.telemetry.model.AnonymizationRule)11 ArrayList (java.util.ArrayList)8 Test (org.junit.jupiter.api.Test)6 AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)4 AccountTelemetryConfig (com.sequenceiq.environment.configuration.telemetry.AccountTelemetryConfig)2 Pattern (jregex.Pattern)2 Replacer (jregex.Replacer)2 CrnResourceDescriptor (com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor)1 RegionAwareCrnGenerator (com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Features (com.sequenceiq.common.api.telemetry.model.Features)1 AccountTelemetryRepository (com.sequenceiq.environment.telemetry.repository.AccountTelemetryRepository)1 Base64 (java.util.Base64)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 PatternSyntaxException (jregex.PatternSyntaxException)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1