The-OAG-Development-Project / Application-Gateway

OWASP Application Gateway is an HTTP proxy that handles Oauth2 authentication and session management
https://owasp.org/www-project-application-gateway/
Apache License 2.0
83 stars 4 forks source link

Fix DefaultKeyRotationTest #92

Closed gianlucafrei closed 3 years ago

gianlucafrei commented 3 years ago

The following test currently fails sometimes, but also succeeds sometimes. That's why it's currently disabled. It seems like the error is because of the Spring scheduling. Please re-enable the test after it twas fixed.

@Disabled("Sometime fails, please FIX")
    @Test
    void keyRotationTest() throws InterruptedException {
        // here the rotationImpl should be initialized and a valid key set
        assertNotNull(signingKeyHolder.getCurrentPrivateKey());
        assertNotNull(signingKeyHolder.getKid());
        String oldKid = signingKeyHolder.getKid();
        PrivateKey oldKey = signingKeyHolder.getCurrentPrivateKey();

        // we have to wait to let key rotation happen
        Thread.sleep(4000);

        assertNotEquals(oldKid, signingKeyHolder.getKid());
        assertNotEquals(oldKey, signingKeyHolder.getCurrentPrivateKey());
    }