Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add acceptLicense method to MSSQLServerContainer #2085

Merged
merged 2 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/modules/databases/mssqlserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Running MS SQL Server as a stand-in for in a test:
public class SomeTest {

@Rule
public MSSQLServerContainer mssqlserver = new MSSQLServerContainer();
public MSSQLServerContainer mssqlserver = new MSSQLServerContainer()
.acceptLicense();

@Test
public void someTestMethod() {
Expand All @@ -20,7 +21,7 @@ public class SomeTest {
```

!!! warning "EULA Acceptance"
Due to licencing restrictions you are required to accept an EULA for this container image. To indicate that you accept the MS SQL Server image EULA, Please place a file at the root of the classpath named `container-license-acceptance.txt`, e.g. at `src/test/resources/container-license-acceptance.txt`. This file should contain the line: `mcr.microsoft.com/mssql/server:2017-CU12` (or, if you are overriding the docker image name/tag, update accordingly).
Due to licencing restrictions you are required to accept an EULA for this container image. To indicate that you accept the MS SQL Server image EULA, call the `acceptLicense()` method, or place a file at the root of the classpath named `container-license-acceptance.txt`, e.g. at `src/test/resources/container-license-acceptance.txt`. This file should contain the line: `mcr.microsoft.com/mssql/server:2017-CU12` (or, if you are overriding the docker image name/tag, update accordingly).

Please see the [`microsoft-mssql-server` image documentation](https://hub.docker.com/_/microsoft-mssql-server#environment-variables) for a link to the EULA document.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,24 @@ protected Integer getLivenessCheckPort() {

@Override
protected void configure() {
LicenseAcceptance.assertLicenseAccepted(this.getDockerImageName());
addEnv("ACCEPT_EULA", "Y");
// If license was not accepted programatically, check if it was accepted via resource file
if (!getEnvMap().containsKey("ACCEPT_EULA")) {
LicenseAcceptance.assertLicenseAccepted(this.getDockerImageName());
acceptLicense();
}

addEnv("SA_PASSWORD", password);
}

/**
* Accepts the license for the SQLServer container by setting the ACCEPT_EULA=Y
* variable as described at <a href="https://hub.docker.com/_/microsoft-mssql-server">https://hub.docker.com/_/microsoft-mssql-server</a>
*/
public SELF acceptLicense() {
addEnv("ACCEPT_EULA", "Y");
return self();
}

@Override
public String getDriverClassName() {
return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
Expand Down Expand Up @@ -116,6 +129,5 @@ private void checkPasswordStrength(String password) {
"or percent (%)."
);
}

}
}