Add test container for UT of MySQL passwordless feature
See original GitHub issueContext
Now we have PasswordlessMySQLIT to test our passwordless feature for Azure MySQL single server, but it can’t run on local env and it takes a lot of time to run(> 10mins).
With Testcontainers for java, we can create data access layer integration tests and run the tests locally to ensure our code quality.
Goal
- Use Testcontainers to mock Azure MySQL single server.
- Add test class to test passwordless feature with Testcontainers.
Design
- Add test class under test folder in spring-cloud-azure-integration-tests.
- In the test class:
- Use DefaultAzureCredentialBuilder to build DefaultAzureCredential to get token with scopes “https://ossrdbms-aad.database.windows.net/.default”.
- the scopes vary in different Clouds.(“Public,UsGov,China”)
- use the token as the password to initialize the test container with mysql.
- specify the spring.datasourcce.* properties with the test container url.
private DockerImageName dockerImageName = DockerImageName.parse("mysql");
@Container
public MySQLContainer mySQLContainer = new MySQLContainer(dockerImageName);
@BeforeEach
void setUp() {
DefaultAzureCredential build = new DefaultAzureCredentialBuilder().build();
// the scopes vary in different Clouds
String password = build.getToken(new TokenRequestContext().addScopes("https://ossrdbms-aad.database.windows.net/.default"))
.block()
.getToken();
mySQLContainer.withUsername("passwordless-test")
.withPassword(password);
}
@Test
void testMysqlPassword() {
// add your
}
Issue Analytics
- State:
- Created a year ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
MySQL Module - Testcontainers for Java
If no custom password is specified, the container will use the default user password test for the root user as well. When you...
Read more >Security in MySQL :: 4.15 Password Management
If an account is restricted on the basis of number of password changes, a new password cannot be chosen from a specified number...
Read more >Migrate an application to use passwordless connections with ...
Learn how to migrate existing applications using Azure Database for MySQL away from authentication patterns such as passwords to more secure ...
Read more >establishing connection with privileged user (mysql) · Issue #682
Else adding this feature after merging the mentioned PR would ... there anyway to create schemas in a mysql test containers instance or...
Read more >How To Set, Change, and Retrieve Your MySQL Root Password
Log in as root into your server through SSH (eg: puTTY/terminal/bash). Alternatively, run the commands that follow as su or sudo as root...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, testcontainers has an azure pipeline to run in windows, see here. Hope this help.
Does this have anything to do with SSL? @Netyyyy can we try without our plugin, but using a raw JDBC with program generated password?