public void Calls_api_authentication_class()
        {
            var oAuthAccessToken = new OAuthAccessToken();

            _oAuthAuthentication.Stub(x => x.ForUser("test", "test")).Return(oAuthAccessToken);
            var sevenDigitalCredentialsAuthProvider = new SevenDigitalCredentialsAuthProvider(_oAuthAuthentication, _userApi);

            var authService = MockRepository.GenerateStub <IServiceBase>();

            authService.Stub(x => x.RequestContext).Return(new MockRequestContext());

            var isAuthenticated = sevenDigitalCredentialsAuthProvider.TryAuthenticate(authService, "test", "test");

            _oAuthAuthentication.AssertWasCalled(x => x.ForUser("test", "test"));
            Assert.That(isAuthenticated);
        }
Beispiel #2
0
        public void Fires_create_method_and_then_logs_in()
        {
            const string expectedUsername = "******";
            const string expectedPassword = "******";

            var oAuthAccessToken = new OAuthAccessToken();

            _oAuthAuthentication.Stub(x => x.ForUser(null, null)).IgnoreArguments().Return(oAuthAccessToken);

            var serviceBase = MockRepository.GenerateStub <IServiceBase>();

            serviceBase.Stub(x => x.RequestContext).Return(new MockRequestContext());
            var sevenDigitalCredentialsAuthProvider = new SevenDigitalCredentialsAuthProvider(_oAuthAuthentication, _userApi);

            sevenDigitalCredentialsAuthProvider.TryAuthenticate(serviceBase, expectedUsername, expectedPassword);
            _userApi.AssertWasCalled(x => x.Create(expectedUsername, expectedPassword, ""));
            _oAuthAuthentication.AssertWasCalled(x => x.ForUser(HttpUtility.UrlEncode(expectedUsername), HttpUtility.UrlEncode(expectedPassword)));
        }