-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jans-auth-server): fixed key rotation and added test to key gener…
…ator context #3415
- Loading branch information
Showing
5 changed files
with
110 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
jans-auth-server/client/src/test/java/io/jans/as/client/util/KeyGeneratorContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.jans.as.client.util; | ||
|
||
import io.jans.as.model.jwk.KeyOps; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Calendar; | ||
|
||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
public class KeyGeneratorContextTest { | ||
|
||
@Test | ||
public void getExpirationForKeyOps_forConnectKeyOps_shouldReturnPassedExpiration() { | ||
KeyGeneratorContext context = new KeyGeneratorContext(); | ||
context.setExpirationHours(1); | ||
|
||
final long expirationForKeyOps = context.getExpirationForKeyOps(KeyOps.CONNECT); | ||
|
||
assertTrue(expirationForKeyOps < futureIn2Hours()); | ||
} | ||
|
||
@Test | ||
public void getExpirationForKeyOps_forSSAKeyOps_shouldReturnExpirationFarInFuture() { | ||
KeyGeneratorContext context = new KeyGeneratorContext(); | ||
context.setExpirationHours(1); | ||
|
||
final long expirationForKeyOps = context.getExpirationForKeyOps(KeyOps.SSA); | ||
|
||
assertTrue(expirationForKeyOps > futureIn2Hours()); | ||
} | ||
|
||
private long futureIn2Hours() { | ||
Calendar future2hours = Calendar.getInstance(); | ||
future2hours.add(2, Calendar.HOUR_OF_DAY); | ||
return future2hours.getTimeInMillis(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters