Exemplo n.º 1
0
 public ProfileControllerTests(ProfileFixture fixture)
 {
     _controller = fixture.Scope.ServiceProvider.GetService <ProfileController>();
     _dao        = fixture.Scope.ServiceProvider.GetService <IProfileDao>();
     _attribute  = fixture.Attribute;
     _profile    = fixture.Profile;
 }
 public AuthenticationService(
     IProfileDao profileDao, 
     IRsaTokenDao rsaToken)
 {
     this.profileDao = profileDao;
     this.rsaToken = rsaToken;
 }
Exemplo n.º 3
0
 public AuthenticationService(IProfileDao profileDao, IFailedCounter failedCounter, ISlackAdapter slackAdapter, ISha256Adapter sha256Adapter, IOtpService otpService, ILogger logger)
 {
     _profileDao    = profileDao;
     _failedCounter = failedCounter;
     _slackAdapter  = slackAdapter;
     _sha256Adapter = sha256Adapter;
     _otpService    = otpService;
     _logger        = logger;
 }
        public void SetUp()
        {
            _fakeProfileDao        = Substitute.For <IProfileDao>();
            _fakeHash              = Substitute.For <IHash>();
            _fakeOtp               = Substitute.For <IOtp>();
            _authenticationService = new AuthenticationService(_fakeProfileDao, _fakeHash, _fakeOtp);

            GivenPassword(DefaultAccountId, DefaultPassword);
            GivenHashedPassword(DefaultPassword, DefaultPassword);
            GivenCurrentOtp(DefaultOtp);
        }
        public bool IsValid(string account, string password, IProfileDao profile, IRsaToken rsaToken)
        {
            // 根據 account 取得自訂密碼
            var passwordFromDao = profile.GetPassword(account);

            // 根據 account 取得 RSA token 目前的亂數
            var randomCode = rsaToken.GetRandom(account);

            // 驗證傳入的 password 是否等於自訂密碼 + RSA token亂數
            var validPassword = passwordFromDao + randomCode;
            var isValid = password == validPassword;
            return isValid;
        }
Exemplo n.º 6
0
 public void Setup()
 {
     _ProfileDao            = Substitute.For <IProfileDao>();
     _Otp                   = Substitute.For <IOtp>();
     _Hash                  = Substitute.For <IHash>();
     _FailCounter           = Substitute.For <IFailCounter>();
     _Notification          = Substitute.For <INotification>();
     _Logger                = Substitute.For <ILogger>();
     _AuthenticationService = new AuthenticationService(_ProfileDao, _Hash, _Otp);
     //composite
     _AuthenticationService = new NotificationDecorator(_AuthenticationService, _Notification);
     _AuthenticationService = new LogFailedCountDecorator(_AuthenticationService, _FailCounter, _Logger);
     _AuthenticationService = new FailedCounterDecorator(_AuthenticationService, _FailCounter);
 }
Exemplo n.º 7
0
        public bool IsValid(string account, string password, IProfileDao profile, IRsaToken rsaToken)
        {
            // 根據 account 取得自訂密碼
            var passwordFromDao = profile.GetPassword(account);

            // 根據 account 取得 RSA token 目前的亂數
            var randomCode = rsaToken.GetRandom(account);

            // 驗證傳入的 password 是否等於自訂密碼 + RSA token亂數
            var validPassword = passwordFromDao + randomCode;
            var isValid       = password == validPassword;

            return(isValid);
        }
Exemplo n.º 8
0
    public ProfileController(IEnumerable <IProvider <Message> > providers, ITelegramBotClient telegram,
                             IProfileDao dao) : base(providers)
    {
        _telegram = telegram;
        _dao      = dao;

        NewAttribute();
        NewProfile();
        AddProfileAlias();
        AddProfileKarma();
        SetProfileAttributeValue();
        ListAttributes();
        ShowAttributeValues();
        ShowTop();
        ShowProfile();
    }
        public void IsValidTest()
        {
            //var stubProfile = new StubProfileDao();
            IProfileDao stubProfile = Substitute.For <IProfileDao>();

            stubProfile.GetPassword("joey").Returns("91");

            //var stubToken = new StubTokenDao();
            IRsaToken stubToken = Substitute.For <IRsaToken>();

            stubToken.GetRandom("").ReturnsForAnyArgs("000000");

            var target = new AuthenticationService(stubProfile, stubToken);

            var actual = target.IsValid("joey", "91000000");

            Assert.IsTrue(actual);
        }
Exemplo n.º 10
0
        public void Test_IsValid_joey_1234666666_Should_Return_True()
        {
            var target   = new AuthService();
            var account  = "cash";
            var password = "******";

            IProfileDao stubProfileDao = Substitute.For <IProfileDao>();

            stubProfileDao.GetPassword("cash").ReturnsForAnyArgs("1234");
            stubProfileDao.GetToken("cash").ReturnsForAnyArgs("666666");

            target.MyProfileDao = stubProfileDao;

            var actual = target.IsValid(account, password);

            var expected = true;

            actual.Should().Be(expected);
        }
 public AuthenticationService(IProfileDao profileDao, IRsaToken rsaToken)
 {
     this.profileDao = profileDao;
     this.rsaToken   = rsaToken;
 }
Exemplo n.º 12
0
 private ProfileService()
 {
     _daoManager = ServiceConfig.GetInstance().DaoManager;
     _Dao        = (IProfileDao)_daoManager.GetDao(typeof(IProfileDao));
 }
Exemplo n.º 13
0
 public void Init()
 {
     _fakeRsaTokenDao = Substitute.For <IRsaTokenDao>();
     _fakeProfileDao  = Substitute.For <IProfileDao>();
     _logService      = Substitute.For <ILogService>();
 }
Exemplo n.º 14
0
 public ProfileDaoTests(ProfileFixture fixture)
 {
     _dao       = fixture.Scope.ServiceProvider.GetService <IProfileDao>();
     _attribute = fixture.Attribute;
     _profile   = fixture.Profile;
 }
Exemplo n.º 15
0
 public AuthenticationService(IProfileDao profileDao, IHash sha256Adapter, IOtp otpService)
 {
     _profileDao    = profileDao;
     _sha256Adapter = sha256Adapter;
     _otpService    = otpService;
 }
 public ProfileLogic(IProfileDao profileDao)
 {
     this._profileDao = profileDao;
 }
Exemplo n.º 17
0
 public AuthenticationService(IProfileDao profileDao, ITokenDao tokenDao)
 {
     this._profileDao = profileDao;
     this._tokenDao = tokenDao;
 }
 public Lab1AuthenticationService(IProfileDao profileDao, IRsaTokenDao rsaTokenDao, ILogService logService)
 {
     _profileDao  = profileDao;
     _rsaTokenDao = rsaTokenDao;
     _logService  = logService;
 }
Exemplo n.º 19
0
 public AuthenticationService()
 {
     _ProfileDao = new ProfileDao();
     _Hash       = new Sha256Adapter();
     _Otp        = new Otp();
 }
Exemplo n.º 20
0
 public AuthenticationService(IProfileDao profileDao, IHash hash, IOtp otp)
 {
     _ProfileDao = profileDao;
     _Hash       = hash;
     _Otp        = otp;
 }