forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support AM/PM in MSI token (Azure#7356)
* Support AM/PM in MSI token * Fix tests * Use SerializerAdapter * opens implementation to jackson * Remove deserialization in msi token test * Revert back to default locale * Remove unused import
- Loading branch information
1 parent
10e4bd5
commit 0c76069
Showing
3 changed files
with
56 additions
and
20 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
...dentity/azure-identity/src/test/java/com/azure/identity/implementation/MSITokenTests.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 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.identity.implementation; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.time.ZoneOffset; | ||
|
||
public class MSITokenTests { | ||
private OffsetDateTime expected = OffsetDateTime.of(2020, 1, 10, 15, 1, 28, 0, ZoneOffset.UTC); | ||
|
||
@Test | ||
public void canParseLong() { | ||
MSIToken token = new MSIToken("fake_token", "1578668608"); | ||
Assert.assertEquals(expected.toEpochSecond(), token.getExpiresAt().toEpochSecond()); | ||
} | ||
|
||
@Test | ||
public void canParseDateTime24Hr() { | ||
MSIToken token = new MSIToken("fake_token", "01/10/2020 15:03:28 +00:00"); | ||
Assert.assertEquals(expected.toEpochSecond(), token.getExpiresAt().toEpochSecond()); | ||
} | ||
|
||
@Test | ||
public void canParseDateTime12Hr() { | ||
MSIToken token = new MSIToken("fake_token", "1/10/2020 3:03:28 PM +00:00"); | ||
Assert.assertEquals(expected.toEpochSecond(), token.getExpiresAt().toEpochSecond()); | ||
|
||
token = new MSIToken("fake_token", "12/20/2019 4:58:20 AM +00:00"); | ||
expected = OffsetDateTime.of(2019, 12, 20, 4, 56, 20, 0, ZoneOffset.UTC); | ||
Assert.assertEquals(expected.toEpochSecond(), token.getExpiresAt().toEpochSecond()); | ||
|
||
token = new MSIToken("fake_token", "1/1/2020 0:00:00 PM +00:00"); | ||
expected = OffsetDateTime.of(2020, 1, 1, 11, 58, 0, 0, ZoneOffset.UTC); | ||
Assert.assertEquals(expected.toEpochSecond(), token.getExpiresAt().toEpochSecond()); | ||
} | ||
} |