Ejemplo n.º 1
0
        public void AirlineFacadeModifyAirlineDetailsMethodEmptyPasswordException()
        {
            ILoggedInAdministratorFacade adminFacade = (ILoggedInAdministratorFacade)TestConfig.fcs.Login(AirlineProjectConfig.ADMIN_USERNAME, AirlineProjectConfig.ADMIN_PASSWORD, out ILoginToken adminToken);

            adminFacade.CreateNewAirline((LoginToken <Administrator>)adminToken, TestData.airline1);

            ILoggedInAirlineFacade airlineFacade1 = (ILoggedInAirlineFacade)TestConfig.fcs.Login(TestData.airline1.UserName, TestData.airline1.Password, out ILoginToken airlineToken1);

            airlineFacade1.ChangeMyPassword((LoginToken <AirlineCompany>)airlineToken1, TestData.airline1.Password, "");
        }
        public void AirlineCompanyFacadeFacade_ChangeMyPassword_PasswordChanged()
        {
            InitDBUnitTest.InitDB();
            AirlineCompany               airlineCompany1      = AdministratorFacade_CreateNewAirline1();
            ILoggedInAirlineFacade       airlineCompanyFacade = GetAirlineCompanyFacade(out LoginToken <AirlineCompany> tAirlineCompany);
            ILoggedInAdministratorFacade administratorFacade  = GetAdministratorFacade(out LoginToken <Administrator> tAdministrator);

            airlineCompanyFacade.ChangeMyPassword(tAirlineCompany, tAirlineCompany.User.PASSWORD, TestResource.AirlineCompanyFacade_NewPassword_PASSWORD);
            AirlineCompany airlineCompany2 = administratorFacade.GetAirlineCompanyById(tAdministrator, airlineCompany1.ID);

            Assert.AreNotEqual(null, airlineCompany2);
            Assert.AreEqual(TestResource.AirlineCompanyFacade_NewPassword_PASSWORD, airlineCompany2.PASSWORD);
        }
Ejemplo n.º 3
0
        public void AirlineFacadeChangeMyPasswordMethod()
        {
            ILoggedInAdministratorFacade adminFacade = (ILoggedInAdministratorFacade)TestConfig.fcs.Login(AirlineProjectConfig.ADMIN_USERNAME, AirlineProjectConfig.ADMIN_PASSWORD, out ILoginToken adminToken);

            adminFacade.CreateNewAirline((LoginToken <Administrator>)adminToken, TestData.airline1);

            ILoggedInAirlineFacade airlineFacade = (ILoggedInAirlineFacade)TestConfig.fcs.Login(TestData.airline1.UserName, TestData.airline1.Password, out ILoginToken airlineToken);

            airlineFacade.ChangeMyPassword((LoginToken <AirlineCompany>)airlineToken, TestData.airline1.Password, "54321");

            IAnonymousUserFacade anonymousFacade = (IAnonymousUserFacade)TestConfig.fcs.Login("testAnonymous", "99999", out ILoginToken anonymousToken);

            Assert.AreEqual("54321", anonymousFacade.GetAirlineCompanyById(TestData.airline1.ID).Password);
        }
        public async Task <ActionResult> ChangeMyPassword([FromBody] UserDetailsDTO userDetails)
        {
            LoginToken <AirlineCompany> token = GetLoginToken();

            try
            {
                await Task.Run(() => m_facade.ChangeMyPassword(token, token.User.Password, userDetails.Password));
            }
            catch (WrongCredentialsException ex)
            {
                return(StatusCode(403, $"{{ error: \"{ex.Message}\" }}"));
            }
            catch (WasntActivatedByAirlineException ex)
            {
                return(StatusCode(401, $"{{ error: \"{ex.Message}\" }}"));
            }
            return(Ok());
        }
        public IHttpActionResult ChangeMyPassword([FromBody] ChangePassword changePass)
        {
            GetLoginToken();
            if (airlineCompanyLoginToken == null)
            {
                return(Unauthorized());
            }
            FCS = FlyingCenterSystem.GetFlyingCenterSystemInstance();
            ILoggedInAirlineFacade airlineCompanyFacade = FCS.GetFacade(airlineCompanyLoginToken) as ILoggedInAirlineFacade;

            try
            {
                airlineCompanyFacade.ChangeMyPassword(airlineCompanyLoginToken, changePass.oldPassword, changePass.newPassword);
                return(Ok("Password changed"));
            }
            catch (Exception e1)
            {
                return(BadRequest(e1.Message));
            }
        }