예제 #1
0
 public final function setUp()
 {
     // run the default setUp() method first
     parent::setUp();
     // create and insert a Profile
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $this->voteProfile = new Profile(null, true, null, "Email", "myName", $hash, 1, "mynameagain", "867", $salt, "yes");
     $this->voteProfile->insert($this->getPDO());
     // create and insert an Image
     $this->voteImage = new Image(null, $this->voteProfile->getProfileId(), "jpeg", "myfile", "theText", null);
     $this->voteImage->insert($this->getPDO());
 }
예제 #2
0
 /**
  * Create dependent objects before running each test
  **/
 public final function setUp()
 {
     //Run the default setUp() method first
     parent::setUp();
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $verify = $salt;
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     //Create and insert a profile for the follower object
     $this->follower = new Profile(null, true, null, "Email", "myName", $hash, 1, "First", "Last", "867", $salt, $verify);
     $this->follower->insert($this->getPDO());
     $this->followed = new Profile(null, true, null, "Email2", "myName2", $hash, 2, "Given", "Family", "5309", $salt, $verify);
     $this->followed->insert($this->getPDO());
 }
예제 #3
0
 public final function setUp()
 {
     //Run the default setUp() method first
     parent::setUp();
     //Create and insert a Profile to post the test Comment
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $verify = $salt;
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $this->profile = new Profile(null, true, null, "Email", "myName", $hash, 1, "First", "Last", "867", $salt, $verify);
     $this->profile->insert($this->getPDO());
     $this->image = new Image(null, $this->profile->getProfileId(), "jpeg", "myfile", "theText", null);
     $this->image->insert($this->getPDO());
     //Calculate the date
     $this->VALID_COMMENTDATE = new \DateTime();
 }
예제 #4
0
 /**
  * Create dependant objects before running each test
  **/
 public final function setUp()
 {
     //Run the default setUp() method first
     parent::setUp();
     //create and insert profile to tag image
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $verify = $salt;
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $this->profile = new Profile(null, true, null, "Email", "myName", $hash, 1, "mynameagain", "867", $salt, $verify);
     $this->profile->insert($this->getPDO());
     //create an image to be tagged
     $this->imageTagImage = new Image(null, $this->profile->getProfileId(), "jpeg", "myfile", "theText", null);
     $this->imageTagImage->insert($this->getPDO());
     $this->imageTagTag = new Tag(null, "Photo");
     $this->imageTagTag->insert($this->getPDO());
 }
예제 #5
0
     $reply->message = "Profile has been updated";
     //post
 } elseif ($method === "POST") {
     // Verify that they are trying to update their own profile
     //		$security = Profile::getProfileByProfileId($pdo, $_SESSION["profile"]->getProfileId());
     //		if($security->getProfileId() === false) {
     //			$_SESSION["profile"]->setProfileId(false);
     //			throw(new RunTimeException("Access Denied", 403));
     //		}
     $password = $requestObject->profilePassword;
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $profileVerify = bin2hex(openssl_random_pseudo_bytes(8));
     //create new Profile
     $profile = new Profile(null, false, null, $requestObject->profileEmail, $requestObject->profileHandle, $hash, 4414, $requestObject->profileNameF, $requestObject->profileNameL, $requestObject->profilePhone, $salt, $profileVerify);
     $profile->insert($pdo);
     $_SESSION["profile"] = $profile;
     $reply->message = "Profile has been created";
     //compose and send the email for confirmation and setting a new password
     // create Swift message
     $swiftMessage = Swift_Message::newInstance();
     // attach the sender to the message
     // this takes the form of an associative array where the Email is the key for the real name
     $swiftMessage->setFrom(["*****@*****.**" => "Jpegery"]);
     /**
      * attach the recipients to the message
      * this is an array that can include or omit the the recipient's real name
      * use the recipients' real name where possible; this reduces the probability of the Email being marked as spam
      **/
     $recipients = [$requestObject->profileEmail];
     $swiftMessage->setTo($recipients);
예제 #6
0
 /**
  * test inserting a Profile and regrabbing it from mySQL
  **/
 public function testGetValidProfileByProfileId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("profile");
     // create a new Profile and insert to into mySQL
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $profile = new Profile(null, $this->VALID_PROFILEADMIN, $this->VALID_PROFILECREATEDATE, $this->VALID_PROFILEEMAIL, $this->VALID_PROFILEHANDLE, $hash, $this->VALID_PROFILEIMAGEID, $this->VALID_PROFILENAME, $this->VALID_PROFILEPHONE, $salt, $this->VALID_PROFILEVERIFY);
     $profile->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProfile = Profile::getProfileByProfileId($this->getPDO(), $profile->getProfileId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("profile"));
     $this->assertEquals($pdoProfile->getProfileId(), $profile->getProfileId());
     $this->assertEquals($pdoProfile->getProfileAdmin(), $this->VALID_PROFILEADMIN);
     $this->assertEquals($pdoProfile->getProfileCreateDate(), $this->VALID_PROFILECREATEDATE);
     $this->assertEquals($pdoProfile->getProfileEmail(), $this->VALID_PROFILEEMAIL);
     $this->assertEquals($pdoProfile->getProfileHandle(), $this->VALID_PROFILEHANDLE);
     $this->assertEquals($pdoProfile->getProfileHash(), $hash);
     $this->assertEquals($pdoProfile->getProfileImageId(), $this->VALID_PROFILEIMAGEID);
     $this->assertEquals($pdoProfile->getProfileName(), $this->VALID_PROFILENAME);
     $this->assertEquals($pdoProfile->getProfilePhone(), $this->VALID_PROFILEPHONE);
     $this->assertEquals($pdoProfile->getProfileSalt(), $salt);
     $this->assertEquals($pdoProfile->getProfileVerify(), $this->VALID_PROFILEVERIFY);
 }