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()); }
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(); }
/** * 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()); }
<?php require_once __DIR__ . "/php/classes/autoload.php"; require_once __DIR__ . "/lib/xsrf.php"; require_once "/etc/apache2/capstone-mysql/encrypted-config.php"; use Edu\Cnm\Jpegery\Profile; use Edu\Cnm\Jpegery\Image; if (session_status() !== PHP_SESSION_ACTIVE) { session_start(); } $reply = new stdClass(); $reply->status = 200; try { $pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/jpegery.ini"); $caption = filter_input(INPUT_POST, "caption", FILTER_SANITIZE_STRING); $image = new Image(null, $_SESSION["profile"]->getProfileId(), "temporaryType", "temporaryName", $caption, null); $image->insert($pdo); $image->imageUpload(); //Connect to encrypted mySQL $image->update($pdo); $reply->message = "This worked. Or didn't and you somehow screwed it up so much you got a false positive. Either way, good job."; $reply->data = $image; } catch (Exception $exception) { $reply->status = $exception->getCode(); $reply->data = $exception->getMessage(); } //Echo the json, encode the $reply. header("Content-type: application/html"); echo json_encode($reply);