Skip to content

Commit

Permalink
Merge pull request #1141 from OWASP/nbaars/1139
Browse files Browse the repository at this point in the history
feat: run Cypress test against pre-compiled HTML
  • Loading branch information
commjoen authored Dec 14, 2023
2 parents 14b65e0 + 4bd8190 commit a1158f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<argLine>-Dspring.profiles.active=test,maven-test</argLine>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
26 changes: 24 additions & 2 deletions src/test/java/org/owasp/wrongsecrets/CypressIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
import org.junit.jupiter.api.DynamicContainer;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.owasp.wrongsecrets.asciidoc.AsciiDocGenerator;
import org.owasp.wrongsecrets.asciidoc.PreCompiledGenerator;
import org.owasp.wrongsecrets.asciidoc.TemplateGenerator;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.testcontainers.Testcontainers;

/**
Expand All @@ -35,8 +42,8 @@
"KEEPASSPATH=src/test/resources/alibabacreds.kdbx",
"keepasspath=src/test/resources/alibabacreds.kdbx"
})
@ActiveProfiles("test")
@Slf4j
@Import(CypressIntegrationTest.Configuration.class)
public class CypressIntegrationTest {
@LocalServerPort private int port;

Expand Down Expand Up @@ -80,4 +87,19 @@ private void createContainerFromSuite(
}
dynamicContainers.add(DynamicContainer.dynamicContainer(suite.getTitle(), dynamicTests));
}

@TestConfiguration
static class Configuration {

@Bean
@Primary
public TemplateGenerator generators(Environment environment) {
if (environment.matchesProfiles("maven-test")) {
log.info("Using pre-compiled generator for tests");
return new PreCompiledGenerator();
}
log.info("Using AsciiDoc generator for tests");
return new AsciiDocGenerator();
}
}
}

0 comments on commit a1158f4

Please sign in to comment.