Skip to content

{Profile} Fix: test_get_raw_token fails on non-UTC machine#15131

Merged
jiasli merged 2 commits intoAzure:devfrom
jiasli:token-datetime
Sep 14, 2020
Merged

{Profile} Fix: test_get_raw_token fails on non-UTC machine#15131
jiasli merged 2 commits intoAzure:devfrom
jiasli:token-datetime

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Sep 11, 2020

Description
Inspired by #14718. Fix: test_get_raw_token fails on non-UTC machine.

The test test_get_raw_token was introduced in #14128.

When using az account get-access-token for managed identity, expiresOn will be converted from POSIX to datetime in local timezone. For example, 1593497681 is converted to

  • 2020-06-30 06:14:41.000000 on a UTC machine
  • 2020-06-30 14:14:41.000000 on a UTC+8 machine

The test test_get_raw_token fails is written for a UTC machine on DevOps and this test will fail on a non-UTC machine (such as UTC+8).

This PR patches fromtimestamp with utcfromtimestamp to force expiresOn to be converted to UTC to make the test pass on any machine.

bluca and others added 2 commits September 11, 2020 16:35
…trings

datetime.fromtimestamp will use the machine's locale timezone by
default, causing expiration timestamps to vary depending on the
local setting. Use UTC to ensure they are stable.

(cherry picked from commit ea0b891)
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 11, 2020

Profile

@yonzhan yonzhan added this to the S176 milestone Sep 11, 2020
Copy link
Contributor

@Juliehzl Juliehzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@arrownj arrownj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jiasli jiasli merged commit e37a79a into Azure:dev Sep 14, 2020
@jiasli jiasli deleted the token-datetime branch September 14, 2020 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants