Exemple #1
0
        public async Task GetIdentitiesAsync_Throws_IfGatewayUrlNotInAppSettings()
        {
            // Arrange
            ConfigurationManager.AppSettings["EMA_RuntimeUrl"] = null;
            // ServiceUser should be authenticated to hit the exception
            MobileAppUser user = new MobileAppUser(CreateMockClaimsIdentity(Enumerable.Empty <Claim>(), true));

            user.MobileAppAuthenticationToken = "1234567890";
            NullReferenceException ex = null;

            // Act
            try
            {
                ex = await Assert.ThrowsAsync <NullReferenceException>(() => user.GetIdentityAsync <FacebookCredentials>());
            }
            finally
            {
                // reset the config for future tests
                ConfigurationManager.RefreshSection("appSettings");
            }

            // Assert
            Assert.NotNull(ex);
            Assert.Equal("The 'EMA_RuntimeUrl' app setting is missing from the configuration.", ex.Message);
        }
Exemple #2
0
        public async Task GetIdentitiesAsync_ReturnsNull_IfUserNotAuthenticated()
        {
            // Arrange
            MobileAppUser user = new MobileAppUser(CreateMockClaimsIdentity(Enumerable.Empty <Claim>(), false));

            // Act
            var tokenResult = await user.GetIdentityAsync <FacebookCredentials>();

            // Assert
            Assert.Null(tokenResult);
        }
Exemple #3
0
        public async Task GetIdentitiesAsync_ReturnsNull_IfMobileAppAuthenticationTokenIsNullOrEmpty(string token)
        {
            // Arrange
            MobileAppUser user = new MobileAppUser(CreateMockClaimsIdentity(Enumerable.Empty <Claim>(), true));

            user.MobileAppAuthenticationToken = token;

            // Act
            var tokenResult = await user.GetIdentityAsync <FacebookCredentials>();

            // Assert
            Assert.Null(tokenResult);
        }
        public async Task GetIdentitiesAsync_ReturnsNull_IfUserNotAuthenticated()
        {
            // Arrange
            MobileAppUser user = new MobileAppUser(CreateMockClaimsIdentity(Enumerable.Empty<Claim>(), false));

            // Act
            var tokenResult = await user.GetIdentityAsync<FacebookCredentials>();

            // Assert
            Assert.Null(tokenResult);
        }
        public async Task GetIdentitiesAsync_ReturnsNull_IfMobileAppAuthenticationTokenIsNullOrEmpty(string token)
        {
            // Arrange
            MobileAppUser user = new MobileAppUser(CreateMockClaimsIdentity(Enumerable.Empty<Claim>(), true));
            user.MobileAppAuthenticationToken = token;

            // Act
            var tokenResult = await user.GetIdentityAsync<FacebookCredentials>();

            // Assert
            Assert.Null(tokenResult);
        }
        public async Task GetIdentitiesAsync_Throws_IfGatewayUrlNotInAppSettings()
        {
            // Arrange
            ConfigurationManager.AppSettings["EMA_RuntimeUrl"] = null;
            // ServiceUser should be authenticated to hit the exception
            MobileAppUser user = new MobileAppUser(CreateMockClaimsIdentity(Enumerable.Empty<Claim>(), true));
            user.MobileAppAuthenticationToken = "1234567890";
            NullReferenceException ex = null;

            // Act
            try
            {
                ex = await Assert.ThrowsAsync<NullReferenceException>(() => user.GetIdentityAsync<FacebookCredentials>());
            }
            finally
            {
                // reset the config for future tests
                ConfigurationManager.RefreshSection("appSettings");
            }

            // Assert
            Assert.NotNull(ex);
            Assert.Equal("The 'EMA_RuntimeUrl' app setting is missing from the configuration.", ex.Message);
        }