public function __construct() { $this->cash_test_url = getTestEnv('CASHMUSIC_TEST_URL'); if ($this->cash_test_url == 'http://dev.cashmusic.org:8080') { echo "Test URL is pointing to an external test server, skipping API tests.\n"; $this->cash_test_url = false; } }
function test_getURLContents() { if (getTestEnv('CASHMUSIC_TEST_URL') == 'http://dev.cashmusic.org:8080' && !strpos(CASH_API_URL, 'localhost')) { // Test URL set to remote, so skip the local test echo "Testing getURLContents with cashmusic.org because of remote test URL.\n"; $return = CASHSystem::getURLContents('http://cashmusic.org/'); $this->assertPattern('/cash/', $return); // use google } else { $return = CASHSystem::getURLContents(CASH_API_URL); $this->assertPattern('/"greeting":"hi."/', $return); // using local API URL as firewalls could mess with an external test } }
function __construct() { echo "Testing Paypal Seed\n"; // add a new admin user for this $user_add_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => '*****@*****.**', 'password' => 'thiswillneverbeused', 'is_admin' => 1)); $this->cash_user_id = $user_add_request->response['payload']; // add a new connection $this->paypal_username = getTestEnv("PAYPAL_USERNAME"); if (!$this->paypal_username) { echo "Paypal credentials not found, skipping tests\n"; } $c = new CASHConnection($this->cash_user_id); // the '1' sets a user id=1 $this->paypal_connection_id = $c->setSettings('Paypal', 'com.paypal', array("username" => $this->paypal_username, "password" => getTestEnv("PAYPAL_PASSWORD"), "signature" => getTestEnv("PAYPAL_SIGNATURE"), "sandboxed" => true)); }
function __construct() { // add a new admin user for this $user_add_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => '*****@*****.**', 'password' => 'thiswillneverbeused', 'is_admin' => 1)); $this->cash_user_id = $user_add_request->response['payload']; // add a new connection $this->api_key = getTestEnv("MAILCHIMP_API_KEY"); $c = new CASHConnection($this->cash_user_id); // the '1' sets a user id=1 $this->mailchimp_connection_id = $c->setSettings('MailChimp', 'com.mailchimp', array("key" => $this->api_key, "list" => $this->test_id)); // add a new list $list_add_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'addlist', 'name' => 'Test List', 'description' => 'Test Description', 'user_id' => $this->cash_user_id, 'connection_id' => $this->mailchimp_connection_id)); // should work fine with no description or connection_id $this->test_list_id = $list_add_request->response['payload']; }
function __construct() { echo "Testing S3 Seed\n"; // add a new admin user for this $user_add_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => '*****@*****.**', 'password' => 'thiswillneverbeused', 'is_admin' => 1)); $this->cash_user_id = $user_add_request->response['payload']; $this->timestamp = time(); $this->s3_key = getTestEnv("S3_KEY"); $this->s3_bucket = getTestEnv("S3_BUCKET"); if (!$this->s3_key) { echo "S3 credentials not found, skipping tests\n"; } // add a new connection $c = new CASHConnection($this->cash_user_id); $this->s3_connection_id = $c->setSettings('S3', 'com.amazon', array("key" => $this->s3_key, "secret" => getTestEnv("S3_SECRET"), "bucket" => $this->s3_bucket)); }
public function testRputFile() { if (getTestEnv() == "travis") { return; } $key = 'tmp/testRputFile' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); list($ret, $err) = Qiniu_RS_RputFile($this->client, $this->bucket, $key, __FILE__, null); $this->assertNull($err); var_dump($ret); $this->assertArrayHasKey('hash', $ret); list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
public function __construct() { $this->cc = new cURL(); $this->cash_test_url = getTestEnv('CASHMUSIC_TEST_URL'); if ($this->cash_test_url == 'http://dev.cashmusic.org:8080') { echo "Test URL is pointing to an external test server, skipping integration tests.\n"; $this->cash_test_url = false; } else { echo "Testing basic admin integration at:\n" . $this->cash_test_url . "\n"; // force a static login for CI workers (Travs, etc): $force_login = getTestEnv('CASH_CI_LOGIN'); $force_password = getTestEnv('CASH_CI_PASSWORD'); if ($force_login) { $this->cash_user_login = $force_login; $this->cash_user_password = $force_password; } else { $user_add_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $this->cash_user_login, 'password' => $this->cash_user_password, 'is_admin' => 1)); $this->cash_user_id = $user_add_request->response['payload']; } } }
public function testLargePut() { if (getTestEnv() == "travis") { return; } $key = 'testRioLargePut' . getTid(); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new QiniuRSPutPolicy($this->bucket); $upToken = $putPolicy->Token(null); $putExtra = new QiniuRioPutExtra($this->bucket); $putExtra->Params = array('x:test' => 'test'); $reader = new \MockReader(); list($ret, $err) = QiniuRioUploadClient::Qiniu_Rio_Put($upToken, $key, $reader, QiniuRioPutExtra::QINIU_RIO_BLOCK_SIZE() + 5, $putExtra); $this->assertNull($err); $this->assertEquals($ret['hash'], "lgQEOCZ8Ievliq8XOfZmWTndgOll"); $this->assertEquals($ret['x:test'], "test"); var_dump($ret); list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
} catch (PDOException $e) { echo "\nOh. Shit. Something's wrong. Couldn't add the user to the database. {$e}\n\n"; exit(1); break; } // modify settings files if (file_exists($installer_root . '/../../framework/php/settings/cashmusic.ini.php')) { rename($installer_root . '/../../framework/php/settings/cashmusic.ini.php', $installer_root . '/../../framework/php/settings/cashmusic.ini.pretest.bak'); } if (!copy($installer_root . '/../../framework/php/settings/cashmusic_template.ini.php', $installer_root . '/../../framework/php/settings/cashmusic.ini.php')) { echo '\\nOh. Shit. Something\'s wrong. Couldn\'t write the config file.\\n\\n' . 'the directory you specified for the framework.</p>'; break; } // move source files into place $file_write_success = false; $test_url = getTestEnv("CASHMUSIC_TEST_URL"); if (!$test_url) { $test_url = "http://dev.cashmusic.org:8080"; } if ($db_engine == 'sqlite') { if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'driver = "mysql', 'driver = "sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'debug = 0', 'debug = 1') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "cashmusic', 'database = "cashmusic_test.sqlite') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'apilocation = "http://localhost:8888/interfaces/php/api/', 'apilocation = "' . $test_url . '/interfaces/php/api/') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } } else { if (findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'hostname = "127.0.0.1:8889', 'hostname = "' . $db_server) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'username = "******"' . $db_username) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'password = "******"' . $db_password) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'database = "cashmusic', 'database = "' . $db_name) && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'debug = 0', 'debug = 1') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'apilocation = "http://localhost:8888/interfaces/php/api/', 'apilocation = "' . $test_url . '/interfaces/php/api/') && findReplaceInFile($installer_root . '/../../framework/php/settings/cashmusic.ini.php', 'salt = "I was born of sun beams; Warming up our limbs', 'salt = "' . $system_salt)) { $file_write_success = true; } } if (!$file_write_success) { echo "\nOh. Shit. Something's wrong. We had trouble editing a few files. Please try again.\n\n"; break;
function testAuth() { if ($this->s3_key) { $s3 = new S3Seed($this->cash_user_id, $this->s3_connection_id); $starting_acp = $s3->getAccessControlPolicy($this->s3_bucket); $this->assertTrue(is_array($starting_acp)); $second_email = getTestEnv("S3_2_EMAIL"); $second_key = getTestEnv("S3_2_KEY"); $second_secret = getTestEnv("S3_2_SECRET"); if ($second_email && $second_key && $second_secret) { $auth_success = $s3->authorizeEmailForBucket($this->s3_bucket, $second_email); $this->assertTrue($auth_success); $changed_acp = $s3->getAccessControlPolicy($this->s3_bucket); $this->assertNotEqual($starting_acp, $changed_acp); // add a new connection for the second user $c = new CASHConnection($this->cash_user_id); $new_connection_id = $c->setSettings('S32', 'com.amazon', array("key" => $second_key, "secret" => $second_secret, "bucket" => $this->s3_bucket)); if ($new_connection_id) { $s32 = new S3Seed($this->cash_user_id, $new_connection_id); // now test that we do in fact have upload permission // go through the range of tests — upload, delete, verify $test_filename = dirname(__FILE__) . '/test' . $this->timestamp; $tmp_file = file_put_contents($test_filename, $this->timestamp); $result = $s32->uploadFile($test_filename, false, false); $this->assertTrue($result); $result = $s32->deleteFile('test' . $this->timestamp); $this->assertTrue($result); $full_list = $s32->listAllFiles(); $this->assertFalse(array_key_exists('test' . $this->timestamp, $full_list)); unlink(dirname(__FILE__) . '/test' . $this->timestamp); unset($s32); $acp_success = $s3->setAccessControlPolicy($this->s3_bucket, '', $starting_acp); $this->assertTrue($acp_success); $changed_acp = $s3->getAccessControlPolicy($this->s3_bucket); $this->assertEqual($starting_acp, $changed_acp); } else { echo 'problem adding second S3Seed'; } } } }