Example #1
0
        public void GetTokenExpiryBufferSecondsTest()
        {
            string   token         = Util.Test.Common.TokenHelper.CreateSasToken("azure.devices.net");
            TimeSpan timeRemaining = TokenHelper.GetTokenExpiryTimeRemaining("foo.azuredevices.net", token);

            Assert.True(timeRemaining > TimeSpan.Zero);
        }
Example #2
0
        public void GetIsTokenExpiredTest()
        {
            // Arrange
            DateTime tokenExpiry = DateTime.UtcNow.AddYears(1);
            string   token       = Util.Test.Common.TokenHelper.CreateSasToken("azure.devices.net", tokenExpiry);

            // Act
            TimeSpan expiryTimeRemaining = TokenHelper.GetTokenExpiryTimeRemaining("azure.devices.net", token);

            // Assert
            Assert.True(expiryTimeRemaining - (tokenExpiry - DateTime.UtcNow) < TimeSpan.FromSeconds(1));
        }