public void GetAdminToken_Fails_NotLinuxContainer() { // Arrange _mockEnvironment.Setup(p => p.GetEnvironmentVariable(It.Is <string>(k => k == EnvironmentSettingNames.ContainerName))).Returns <string>(v => v = null); var key = TestHelpers.GenerateKeyBytes(); var stringKey = TestHelpers.GenerateKeyHexString(key); using (new TestScopedEnvironmentVariable(EnvironmentSettingNames.WebSiteAuthEncryptionKey, stringKey)) { // Act ObjectResult result = (ObjectResult)_hostController.GetAdminToken(); HttpStatusCode resultStatus = (HttpStatusCode)result.StatusCode; // Assert Assert.Equal(HttpStatusCode.BadRequest, resultStatus); } }
public void GetAdminToken_Succeeds() { // Arrange _mockEnvironment.Setup(p => p.GetEnvironmentVariable(It.Is <string>(k => k == EnvironmentSettingNames.ContainerName))).Returns <string>(v => v = "ContainerName"); var key = TestHelpers.GenerateKeyBytes(); var stringKey = TestHelpers.GenerateKeyHexString(key); using (new TestScopedEnvironmentVariable(EnvironmentSettingNames.WebSiteAuthEncryptionKey, stringKey)) { // Act ObjectResult result = (ObjectResult)_hostController.GetAdminToken(); HttpStatusCode resultStatus = (HttpStatusCode)result.StatusCode; string token = (string)result.Value; // Assert Assert.Equal(HttpStatusCode.OK, resultStatus); Assert.True(SimpleWebTokenHelper.ValidateToken(token, new SystemClock())); } }