public void SetUp()
		{
			mUserServiceMock = A.Fake<IUserService>();
			mAuthManagerMock = new AuthenticationManagerMock();

			mTestedController = new UserController(mUserServiceMock, mAuthManagerMock);
		}
Example #2
0
        public async Task TestCreateFirewallRuleHandlesTokenExpiration()
        {
            // Given the token has expired
            string serverName = "myserver.database.windows.net";
            var    sub1Mock   = new Mock <IAzureUserAccountSubscriptionContext>();

            SetupCreateSession();
            string expectedErrorMsg = "Token is expired";

            AuthenticationManagerMock.Setup(a => a.GetSubscriptionsAsync()).ThrowsAsync(new ExpiredTokenException(expectedErrorMsg));

            // When I request the firewall be created
            var createFirewallParams = new CreateFirewallRuleParams()
            {
                ServerName            = serverName,
                StartIpAddress        = "1.1.1.1",
                EndIpAddress          = "1.1.1.255",
                Account               = CreateAccount(),
                SecurityTokenMappings = new Dictionary <string, AccountSecurityToken>()
            };
            await TestUtils.RunAndVerify <CreateFirewallRuleResponse>(
                (context) => ResourceProviderService.HandleCreateFirewallRuleRequest(createFirewallParams, context),
                (response) =>
            {
                // Then I expect the response to indicate that we failed due to token expiration
                Assert.NotNull(response);
                Assert.Equal(expectedErrorMsg, response.ErrorMessage);
                Assert.True(response.IsTokenExpiredFailure);
                Assert.False(response.Result);
            });
        }
Example #3
0
 private void SetupReturnsSubscriptions(IEnumerable <IAzureUserAccountSubscriptionContext> subs)
 {
     AuthenticationManagerMock.Setup(a => a.GetSubscriptionsAsync()).Returns(() => Task.FromResult(subs));
 }