Esempio n. 1
0
 public FacebookSpecsBase()
 {
     this.facebookApi = MockRepository.GenerateStub<IFacebookApi>();
     this.formsAuth = MockRepository.GenerateMock<IFormsAuth>();
     this.accountController =
         new AccountControllerBuilder().WithJsonRequest().WithFormsAuth(this.formsAuth).WithFacebookApi(this.facebookApi).Build();
 }
        public AccountControllerBuilder()
        {
            this.formsAuth = MockRepository.GenerateMock<IFormsAuth>();

            this.facebookApi = MockRepository.GenerateStub<IFacebookApi>();
            this.facebookApi.Stub(x => x.GetUserEmail(Arg<string>.Is.Anything)).Return("*****@*****.**");
        }
Esempio n. 3
0
 public AccountController(IFormsAuth formsAuth, IMailer mailer, IFacebookApi facebookApi)
 {
     this.users = new Users();
     this.pwdResetTokens = new PasswordResetTokens();
     this.formsAuth = formsAuth;
     this.mailer = mailer;
     this.facebookApi = facebookApi;
 }
Esempio n. 4
0
 public AccountController(IAppSensor appSensor, IAppConfiguration configuration, IEncryption encryption, IFormsAuth formsAuth, ISeContext context, IHttpCache httpCache, IUserManager userManager, IRecaptcha recaptcha, IServices services, IUserIdentity userIdentity) : base(userIdentity, appSensor)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _context       = context ?? throw new ArgumentNullException(nameof(context));
     _encryption    = encryption ?? throw new ArgumentNullException(nameof(encryption));
     _formsAuth     = formsAuth ?? throw new ArgumentNullException(nameof(formsAuth));
     _httpCache     = httpCache ?? throw new ArgumentNullException(nameof(httpCache));
     _recaptcha     = recaptcha ?? throw new ArgumentNullException(nameof(recaptcha));
     _services      = services ?? throw new ArgumentNullException(nameof(services));
     _userManager   = userManager ?? throw new ArgumentNullException(nameof(userManager));
 }
 public void Setup()
 {
     base.BaseSetup();
     _configuration = MockRepository.GenerateMock <IAppConfiguration>();
     _encryption    = MockRepository.GenerateMock <IEncryption>();
     _formsAuth     = MockRepository.GenerateMock <IFormsAuth>();
     _recaptcha     = MockRepository.GenerateMock <IRecaptcha>();
     _services      = MockRepository.GenerateMock <IServices>();
     _userManager   = MockRepository.GenerateMock <IUserManager>();
     _sut           = new AccountController(_appSensor, _configuration, _encryption, _formsAuth, _context,
                                            _userManager, _recaptcha, _services, _userIdentity);
     _sut.ControllerContext = new ControllerContext(_httpContext, new RouteData(), _sut);
 }
 public void Setup()
 {
     base.BaseSetup();
     _configuration = MockRepository.GenerateStub <IAppConfiguration>();
     _configuration.Stub(a => a.HasRecaptcha).Return(true);
     _encryption  = MockRepository.GenerateMock <IEncryption>();
     _formsAuth   = MockRepository.GenerateMock <IFormsAuth>();
     _userManager = MockRepository.GenerateMock <IUserManager>();
     _recaptcha   = MockRepository.GenerateMock <IRecaptcha>();
     _services    = MockRepository.GenerateMock <IServices>();
     _sut         = new AccountController(_appSensor, _configuration, _encryption, _formsAuth, _context, _userManager, _recaptcha, _services, _userIdentity);
     _httpRequest.Stub(x => x.Url).Return(new Uri("http://localhost/a", UriKind.Absolute));
     _sut.Url = new UrlHelper(new RequestContext(_httpContext, new RouteData()), new RouteCollection());
     _sut.ControllerContext = new ControllerContext(_httpContext, new RouteData(), _sut);
 }
        public UnapprovedUserLogsIn()
        {
            TestUtil.InitDatabase();
            this.AddUnApprovedUserWithFacebookId();
            this.formsAuth = MockRepository.GenerateMock<IFormsAuth>();

            this.facebookApi = MockRepository.GenerateStub<IFacebookApi>();
            this.facebookApi.Stub(x => x.GetUserEmail(Arg<string>.Is.Anything)).Return("*****@*****.**");

            this.accountController =
                new AccountControllerBuilder().WithJsonRequest().WithFormsAuth(this.formsAuth).Build();

            this.result = accountController.FbLogin(
                ConfigurationManager.AppSettings["SignedRequest"],
                ConfigurationManager.AppSettings["AccessToken"],
                "/Login") as JsonResult;
        }
        public UserIsNotConnectedToFacebookApp()
        {
            TestUtil.InitDatabase();
            this.AddUserWithFacebookId();

            this.formsAuth = MockRepository.GenerateMock<IFormsAuth>();
            this.formsAuth.Expect(x => x.SetAuthCookie("*****@*****.**", false));

            this.facebookApi = MockRepository.GenerateStub<IFacebookApi>();
            this.facebookApi.Stub(x => x.GetUserEmail(Arg<string>.Is.Anything)).Return(null);

            this.accountController =
                new AccountControllerBuilder().WithJsonRequest().WithFormsAuth(this.formsAuth).Build();

            this.result = accountController.FbLogin(
                ConfigurationManager.AppSettings["SignedRequest"],
                ConfigurationManager.AppSettings["AccessToken"],
                "/Login") as JsonResult;
        }
        public AccountController(IAppSensor appSensor, IAppConfiguration configuration, IEncryption encryption, IFormsAuth formsAuth, ISEContext context, IUserManager userManager, IRecaptcha recaptcha, IServices services, IUserIdentity userIdentity) : base(userIdentity, appSensor)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (encryption == null)
            {
                throw new ArgumentNullException("encryption");
            }
            if (formsAuth == null)
            {
                throw new ArgumentNullException("formsAuth");
            }
            if (recaptcha == null)
            {
                throw new ArgumentNullException("recaptcha");
            }
            if (services == null)
            {
                throw new ArgumentNullException("services");
            }
            if (userManager == null)
            {
                throw new ArgumentNullException("userManager");
            }

            _configuration = configuration;
            _context       = context;
            _encryption    = encryption;
            _formsAuth     = formsAuth;
            _recaptcha     = recaptcha;
            _services      = services;
            _userManager   = userManager;
        }
        public FacebookApiThrowsWhenGettingEmail()
        {
            // Init database (this will delete all users, so there are no users with facebook ids in there).
            TestUtil.InitDatabase();

            this.usersModel = new Users();
            this.usersModel.Register("*****@*****.**", TestUtil.DefaultUserPassword, TestUtil.DefaultUserPassword);
            dynamic user = this.usersModel.Single(where: "Email = @0", args: "*****@*****.**");
            user.IsApproved = true;
            this.usersModel.Update(user, user.ID);

            this.facebookApi = MockRepository.GenerateStub<IFacebookApi>();
            this.facebookApi.Stub(x => x.GetUserEmail(Arg<string>.Is.Anything)).Return(null);

            this.formsAuth = MockRepository.GenerateMock<IFormsAuth>();

            this.accountController =
                new AccountControllerBuilder().WithJsonRequest().WithFormsAuth(this.formsAuth).WithMailer(this.mailer).WithFacebookApi(this.facebookApi).Build();

            this.result = this.accountController.FbLogin(
                ConfigurationManager.AppSettings["SignedRequest"],
                ConfigurationManager.AppSettings["AccessToken"],
                "/Login") as JsonResult;
        }
Esempio n. 11
0
 public AccountController(IFormsAuth authProvider)
 {
     this._authenticationProvider = authProvider;
 }
Esempio n. 12
0
 public HomeController(IRepositoryUser repositoryUser,
                       IFormsAuth formsAuth)
 {
     this._repositoryUser = repositoryUser;
     this._formsAuth      = formsAuth;
 }
Esempio n. 13
0
 /// <summary>
 /// Class constructor. It initializes the IUserRepository object
 /// </summary>
 public AccountController(IUserRepository userRepo, IFormsAuth formsAuth, IMembership membership)
 {
     _userRepo = userRepo;
     _formsAuth = formsAuth;
     _membership = membership;
 }
 public AccountController(IFormsAuth formAuth)
 {
     this.formAuth = formAuth;
 }
 public AccountControllerBuilder WithFormsAuth(IFormsAuth formsAuth)
 {
     this.formsAuth = formsAuth;
     return this;
 }
Esempio n. 16
0
 public AccountController(IFormsAuth formsAuth)
 {
     this.formsAuth = formsAuth;
 }