Exemplo n.º 1
0
 /**
  * create dependent objects before running each test
  */
 public final function setUp()
 {
     // run the default setUp() method first
     parent::setUp();
     $password = "******";
     $activation = bin2hex(random_bytes(16));
     $salt = bin2hex(random_bytes(32));
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     // creates and inserts Company to sql for User foreign key relations
     $this->company = new Company(null, "Taco B.", "404 Taco St.", "suite:666", "Attention!!", "NM", "Burque", "87106", "5055551111", "*****@*****.**", "www.tocobell.com");
     $this->company->insert($this->getPDO());
     $_SESSION["company"] = $this->company;
     // creates and inserts Crew to sql for User foreign key relations
     $this->crew = new Crew(null, $this->company->getCompanyId(), "the moon");
     $this->crew->insert($this->getPDO());
     // creates and inserts Access to sql for User foreign key relations
     $this->access = new Access(null, "requestor or admin");
     $this->access->insert($this->getPDO());
     // create and insert a User to own the test Request
     $this->requestor = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), "5551212", "Johnny", "Requestorman", "*****@*****.**", $activation, $hash, $salt);
     $this->requestor->insert($this->getPDO());
     $this->admin = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), "5552121", "Suzy", "Hughes", "*****@*****.**", $activation, $hash, $salt);
     $this->admin->insert($this->getPDO());
     // calculate the date (just use the time the unit test was setup...)
     $this->VALID_REQUESTTIMESTAMP = new \DateTime();
     $this->VALID_REQUESTACTIONTIMESTAMP = new \DateTime();
 }
Exemplo n.º 2
0
        //		if($password !== $verifyPassword) {
        //			throw(new InvalidArgumentException ("Password and verify password must match."));
        //		}
        //create a new company for the user
        $company = new Company(null, $companyAttn, $companyName, $companyAddress1, $companyAddress2, $companyCity, $companyState, $companyZip, "111-111-1111", $companyEmail, $companyUrl);
        $company->insert($pdo);
        //create a new crew for the user
        $crew = new Crew(null, $company->getCompanyId(), "");
        $crew->insert($pdo);
        //create new user
        //create password salt, hash and activation code
        $activation = bin2hex(random_bytes(16));
        $salt = bin2hex(random_bytes(32));
        $hash = hash_pbkdf2("sha512", "password", $salt, 262144);
        $user = new User(null, $company->getCompanyId(), $crew->getCrewId(), Access::ADMIN, "5055551212", $userFirstName, $userLastName, $userEmail, $activation, $hash, $salt);
        $user->insert($pdo);
        $messageSubject = "Time Crunch Account Activation";
        //building the activation link that can travel to another server and still work. This is the link that will be clicked to confirm the account.
        // FIXME: make sure URL is /public_html/activation/$activation
        $basePath = dirname($_SERVER["SCRIPT_NAME"], 4);
        $urlglue = $basePath . "/activation/" . $activation;
        $confirmLink = "https://" . $_SERVER["SERVER_NAME"] . $urlglue;
        $message = <<<EOF
<h2>Welcome to the Time Crunch schedule management application.</h2>
<p>Visit the following URL to set a new password and complete the registration process: </p>
<p><a href="{$confirmLink}">{$confirmLink}</a></p>
EOF;
        $response = sendEmail($userEmail, $userFirstName, $userLastName, $messageSubject, $message);
        if ($response === "Email sent.") {
            $reply->message = "Sign up was successful, please check your email for activation message.";
        }
Exemplo n.º 3
0
 /**
  * test grabbing all users
  */
 public function testGetAllValidUsers()
 {
     //create a new user and insert into mySQL
     $user = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), $this->VALID_USERPHONE, $this->VALID_USERFIRSTNAME, $this->VALID_USERLASTNAME, $this->VALID_USEREMAIL, $this->VALID_USERACTIVATION, $this->VALID_USERHASH, $this->VALID_USERSALT);
     $user->insert($this->getPDO());
     //count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("user");
     //grab the data for mySQL and enforce the field match our expectations
     $results = User::getAllUsers($this->getPDO());
     $this->assertEquals($numRows, $results->count());
 }