question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add test container for UT of MySQL passwordless feature

See original GitHub issue

Context

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:open
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
eddumelendezcommented, Dec 7, 2022

Hi, testcontainers has an azure pipeline to run in windows, see here. Hope this help.

1reaction
saraglunacommented, Nov 23, 2022

Does this have anything to do with SSL? @Netyyyy can we try without our plugin, but using a raw JDBC with program generated password?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found