adding missing files to git

This commit is contained in:
Dario Rekowski on RockPI 2020-05-13 13:04:28 +00:00 committed by Dario via Pythagoras
parent e0d22698ef
commit 90678fe42a
13 changed files with 1260 additions and 0 deletions

View File

@ -0,0 +1,51 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Controller;
use App\Controller\AppController;
class ElopageWebhookController extends AppController
{
public function initialize()
{
parent::initialize();
$this->Auth->allow(['put']);
}
public function put()
{
$this->autoRender = false;
$data = $this->request->getData();
$response = $this->response->withType('text/plain');
$dataString = http_build_query($data);
//$this->recursiveArrayToString($data, $dataString);
// %5B => [
// %5D => ]
$dataString = preg_replace(['/\%5B/', '/\%5D/'], ['[', ']'], $dataString);
//var_dump($dataString);
//2020-02-27T13:52:32+01:00
$dateString = date('c');
$fh = fopen('/etc/grd_login/php_elopage_requests.txt', 'a');
if($fh === FALSE) {
return $response->withStringBody('400 ERROR');
}
fwrite($fh, $dateString);
fwrite($fh, "\n");
fwrite($fh, $dataString);
fwrite($fh, "\n");
fclose($fh);
return $response->withStringBody('200 OK');
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* ElopageBuysFixture
*/
class ElopageBuysFixture extends TestFixture
{
/**
* Fields
*
* @var array
*/
// @codingStandardsIgnoreStart
public $fields = [
'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
'elopage_user_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'affiliate_program_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'publisher_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'order_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'product_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'product_price' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'payer_email' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null],
'publisher_email' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null],
'payed' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
'success_date' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null],
'event' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'collate' => 'utf8mb4_general_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
],
'_options' => [
'engine' => 'InnoDB',
'collation' => 'utf8_bin'
],
];
// @codingStandardsIgnoreEnd
/**
* Init method
*
* @return void
*/
public function init()
{
$this->records = [
[
'id' => 1,
'elopage_user_id' => 1,
'affiliate_program_id' => 1,
'publisher_id' => 1,
'order_id' => 1,
'product_id' => 1,
'product_price' => 1,
'payer_email' => 'Lorem ipsum dolor sit amet',
'publisher_email' => 'Lorem ipsum dolor sit amet',
'payed' => 1,
'success_date' => '2020-02-13 09:49:46',
'event' => 'Lorem ipsum dolor sit amet',
],
];
parent::init();
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
/**
* UsersFixture
*/
class UsersFixture extends TestFixture
{
/**
* Fields
*
* @var array
*/
// @codingStandardsIgnoreStart
public $fields = [
'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
'email' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null],
'first_name' => ['type' => 'string', 'length' => 150, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null],
'last_name' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => '', 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null],
'password' => ['type' => 'biginteger', 'length' => 25, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
'pubkey' => ['type' => 'binary', 'length' => 32, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
'privkey' => ['type' => 'binary', 'length' => 80, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
'created' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '', 'precision' => null],
'email_checked' => ['type' => 'boolean', 'length' => null, 'null' => false, 'default' => '0', 'comment' => '', 'precision' => null],
'language' => ['type' => 'string', 'length' => 4, 'null' => false, 'default' => 'de', 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null],
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
'email' => ['type' => 'unique', 'columns' => ['email'], 'length' => []],
],
'_options' => [
'engine' => 'InnoDB',
'collation' => 'utf8_general_ci'
],
];
// @codingStandardsIgnoreEnd
/**
* Init method
*
* @return void
*/
public function init()
{
$this->records = [
[
'id' => 1,
'email' => 'Lorem ipsum dolor sit amet',
'first_name' => 'Lorem ipsum dolor sit amet',
'last_name' => 'Lorem ipsum dolor sit amet',
'password' => 1,
'pubkey' => 'Lorem ipsum dolor sit amet',
'privkey' => 'Lorem ipsum dolor sit amet',
'created' => '2020-02-13 10:54:19',
'email_checked' => 1,
'language' => 'Lo',
],
];
parent::init();
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\ElopageBuysController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\ElopageBuysController Test Case
*
* @uses \App\Controller\ElopageBuysController
*/
class ElopageBuysControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.ElopageBuys',
'app.ElopageUsers',
'app.AffiliatePrograms',
'app.Publishers',
'app.Orders',
'app.Products',
];
/**
* Test index method
*
* @return void
*/
public function testIndex()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test view method
*
* @return void
*/
public function testView()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test add method
*
* @return void
*/
public function testAdd()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test edit method
*
* @return void
*/
public function testEdit()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test delete method
*
* @return void
*/
public function testDelete()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,183 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\JsonRequestHandlerController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\TransactionJsonRequestHandlerController Test Case
*
* @uses \App\Controller\TransactionJsonRequestHandlerController
*/
class JsonRequestHandlerControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.TransactionCreations',
'app.Transactions',
'app.StateUsers',
'app.StateErrors',
'app.TransactionSignatures',
'app.TransactionSendCoins',
'app.StateBalances',
'app.TransactionTypes'
];
public $transactions = [
'validCreation' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQJ8wF12eZo3hcMAlAKKJ9WLT-zuSkNmGh7D98UEqH4KoIysnCkXqEya9EBZl9o11_nJ8xmm_nOevuVjR-GfLMQ8qSQoOSGFsbG8gV2VsdCAxMjMSBgiZm4ruBUovCicKIJSuE1uTzZ8zdStOVcQZA6P6oTp1u5C_1BHqHUoaXnEfEKDakwEQtYntlgo',
'validCreation900' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQNVZ8Ae3Zbg3G0wZ840fzKan6N4KtTcSe0KYi17kQwFmsl18oFxXv8_s6j1xXFrIKjy1_1Olq0a7xYLErDMkjwYqORIGCNb5iu4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgNHKCBC1ie2WCg',
'validCreation1200' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQEEey5QMAdldoOTP_jTETHgOQriGsixEY0cziQeRfT_J5YtbI_A6AizEYD-JcxmRmXzv1xjjTgsV39Y32ta2CQkqORIGCIeGi-4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgOy4CxC1ie2WCg',
'notBase64' => 'CgpIYWxsbyBXZW-0EgYIyfSG7gV_LwonCiCboKikqwjZfes9xuqgthFH3',
'validTransfer' => 'GmYKZAoggZC9pYXuXx2fv30G6B5p7BjhM3YQTP9Ut0V-t9PvcQ0SQDddHyKzAX3LBV0PuDiPc6lxkUipss5tyuLRpMtFJQnT30tsbYIkA1FXimjMKOoiuLswf4OLLV3bAIYehW-b9AgqYQoFSGFsbG8SBgiJlaPvBUJQCiYKIIGQvaWF7l8dn799BugeaewY4TN2EEz_VLdFfrfT73ENEICfSRImCiDtdleSLxhUgEbMW9DpqIwsykFj3-z_enKEOuGnXrmW8xCAn0k',
'errornusTransfer' => 'ClxGcm9oZXMgTmV1ZXMgSmFociB1bmQgREFOS0UsIGRhc3MgZHUgZGljaCBzbyBlaW5zZXR6dCBmw7xyIEdyYWRpZG8hIEhlcnpsaWNoZSBHcsO8w59lIFRlcmVzYRIGCPjjgvEFQlAKJgogUQwFYeVlGlfWDrkXNN7rHwejoCDJKt+YkYJfbJVyj3EQwIQ9EiYKIPXIRnUhVJ/zCs5+y/VaTBjTIoYizJNwS+JC//xsbQrHEMCEPQ==',
'creationValid' => 'GmYKZAogLtKKHPXhFtg2FUBrxXcVIiHC93SlZW9moOdUD3V21xsSQHpXYAGiVmSfhjB3o7OPx0ZJuPXrDk5eu1_AOhQBODU3KpUqBRA9yMX54S_mvGijGubCNRcMLcm7wiYbyAG-3AkqSwoQZWluIE1vbmF0c2dlaGFsdBIGCKqs5vEFSi8KJwoggZC9pYXuXx2fv30G6B5p7BjhM3YQTP9Ut0V-t9PvcQ0QgNrECRDKyd3uAQ'
];
/*public function setUp() {
parent::setUp();
}
*/
public function testWrongMethod()
{
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
$this->get('/JsonRequestHandler');
$this->assertResponseOk();
$expected = json_encode(['state' => 'error', 'msg' => 'no post']);
$this->assertEquals($expected, (string)$this->_response->getBody());
}
public function testInvalidJson()
{
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
$this->post('/JsonRequestHandler', '{This isn\'t valid json}');
$this->assertResponseOk();
$expected = json_encode(['state' => 'error', 'msg' => 'parameter error']);
$this->assertEquals($expected, (string)$this->_response->getBody());
}
public function testNotSetTransaction()
{
$this->postAndParse(
['method' => 'putTransaction'],
['state' => 'error', 'msg' => 'parameter error']
);
}
public function testNotSetMethod()
{
$this->postAndParse(
['transaction' => $this->transactions['validCreation']],
['state' => 'error', 'msg' => 'parameter error']
);
}
public function testUnknownMethod()
{
//$this->post('/TransactionJsonRequestHandler', ['method' => 'putTransaction', 'transaction' => 'CgpIYWxsbyBXZWx0EgYIyfSG7gVKLwonCiCboKikqwjZfes9xuqgthFH3/cHHaWchkUhWiGhQjB23xCg2pMBELWJ7ZYK']);
$this->postAndParse(
['method' => 'foobar', 'transaction' => $this->transactions['validCreation']],
['state' => 'error', 'msg' => 'unknown method', 'details' => 'foobar']
);
}
public function testInvalidEncodedTransaction() {
//"msg":"error parsing transaction","details":[{"Transaction":"base64 decode error"}]
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['notBase64']],
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
['Transaction' => 'invalid base64 string']
]]
);
}
public function testInvalidTransaction() {
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => base64_encode('Hallo Miau Welt')],
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
['Transaction' => 'Error occurred during parsing: Unexpected wire type.']
]]
);
}
public function testToLargeCreationSum()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation900']],
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
);
}
public function testToLargeCreation()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation1200']],
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
);
}
public function testValidTransfer()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validTransfer']],
['state' => 'success']
);
}
/*public function testMissingPreviousTransaction()
{
}*/
public function testValidTransaction()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation']],
['state' => 'success']
);
}
public function testValidCreation()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['creationValid']],
['state' => 'success']
);
}
private function postAndParse($params, $expected)
{
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
$this->disableErrorHandlerMiddleware();
$this->post('/JsonRequestHandler', json_encode($params));
// Check that the response was a 200
$this->assertResponseOk();
$responseBodyString = (string)$this->_response->getBody();
$json = json_decode($responseBodyString);
$this->assertNotFalse($json);
if(is_array($expected)) {
$expected = json_encode($expected);
}
$this->assertEquals($expected, $responseBodyString);
}
}

View File

@ -0,0 +1,174 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\JsonRequestHandlerController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\TransactionJsonRequestHandlerController Test Case
*
* @uses \App\Controller\TransactionJsonRequestHandlerController
*/
class TransactionJsonRequestHandlerControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.TransactionCreations',
'app.Transactions',
'app.StateUsers',
'app.StateErrors',
'app.TransactionSignatures',
'app.TransactionSendCoins',
'app.StateBalances',
'app.TransactionTypes'
];
public $transactions = [
'validCreation' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQJ8wF12eZo3hcMAlAKKJ9WLT-zuSkNmGh7D98UEqH4KoIysnCkXqEya9EBZl9o11_nJ8xmm_nOevuVjR-GfLMQ8qSQoOSGFsbG8gV2VsdCAxMjMSBgiZm4ruBUovCicKIJSuE1uTzZ8zdStOVcQZA6P6oTp1u5C_1BHqHUoaXnEfEKDakwEQtYntlgo',
'validCreation900' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQNVZ8Ae3Zbg3G0wZ840fzKan6N4KtTcSe0KYi17kQwFmsl18oFxXv8_s6j1xXFrIKjy1_1Olq0a7xYLErDMkjwYqORIGCNb5iu4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgNHKCBC1ie2WCg',
'validCreation1200' => 'GmYKZAogYbkjwhjLY6ZKjGLzhgEhKDuVd_N00KMVkLoCzcKRKZkSQEEey5QMAdldoOTP_jTETHgOQriGsixEY0cziQeRfT_J5YtbI_A6AizEYD-JcxmRmXzv1xjjTgsV39Y32ta2CQkqORIGCIeGi-4FSi8KJwoglK4TW5PNnzN1K05VxBkDo_qhOnW7kL_UEeodShpecR8QgOy4CxC1ie2WCg',
'notBase64' => 'CgpIYWxsbyBXZW-0EgYIyfSG7gV_LwonCiCboKikqwjZfes9xuqgthFH3',
'validTransfer' => 'GmYKZAoggZC9pYXuXx2fv30G6B5p7BjhM3YQTP9Ut0V-t9PvcQ0SQDddHyKzAX3LBV0PuDiPc6lxkUipss5tyuLRpMtFJQnT30tsbYIkA1FXimjMKOoiuLswf4OLLV3bAIYehW-b9AgqYQoFSGFsbG8SBgiJlaPvBUJQCiYKIIGQvaWF7l8dn799BugeaewY4TN2EEz_VLdFfrfT73ENEICfSRImCiDtdleSLxhUgEbMW9DpqIwsykFj3-z_enKEOuGnXrmW8xCAn0k',
'errornusTransfer' => 'ClxGcm9oZXMgTmV1ZXMgSmFociB1bmQgREFOS0UsIGRhc3MgZHUgZGljaCBzbyBlaW5zZXR6dCBmw7xyIEdyYWRpZG8hIEhlcnpsaWNoZSBHcsO8w59lIFRlcmVzYRIGCPjjgvEFQlAKJgogUQwFYeVlGlfWDrkXNN7rHwejoCDJKt+YkYJfbJVyj3EQwIQ9EiYKIPXIRnUhVJ/zCs5+y/VaTBjTIoYizJNwS+JC//xsbQrHEMCEPQ=='
];
/*public function setUp() {
parent::setUp();
}
*/
public function testWrongMethod()
{
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
$this->get('/TransactionJsonRequestHandler');
$this->assertResponseOk();
$expected = json_encode(['state' => 'error', 'msg' => 'no post']);
$this->assertEquals($expected, (string)$this->_response->getBody());
}
public function testInvalidJson()
{
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
$this->post('/TransactionJsonRequestHandler', '{This isn\'t valid json}');
$this->assertResponseOk();
$expected = json_encode(['state' => 'error', 'msg' => 'parameter error']);
$this->assertEquals($expected, (string)$this->_response->getBody());
}
public function testNotSetTransaction()
{
$this->postAndParse(
['method' => 'putTransaction'],
['state' => 'error', 'msg' => 'parameter error']
);
}
public function testNotSetMethod()
{
$this->postAndParse(
['transaction' => $this->transactions['validCreation']],
['state' => 'error', 'msg' => 'parameter error']
);
}
public function testUnknownMethod()
{
//$this->post('/TransactionJsonRequestHandler', ['method' => 'putTransaction', 'transaction' => 'CgpIYWxsbyBXZWx0EgYIyfSG7gVKLwonCiCboKikqwjZfes9xuqgthFH3/cHHaWchkUhWiGhQjB23xCg2pMBELWJ7ZYK']);
$this->postAndParse(
['method' => 'foobar', 'transaction' => $this->transactions['validCreation']],
['state' => 'error', 'msg' => 'unknown method', 'details' => 'foobar']
);
}
public function testInvalidEncodedTransaction() {
//"msg":"error parsing transaction","details":[{"Transaction":"base64 decode error"}]
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['notBase64']],
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
['Transaction' => 'invalid base64 string']
]]
);
}
public function testInvalidTransaction() {
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => base64_encode('Hallo Miau Welt')],
['state' => 'error', 'msg' => 'error parsing transaction', 'details' => [
['Transaction' => 'Error occurred during parsing: Unexpected wire type.']
]]
);
}
public function testToLargeCreationSum()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation900']],
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
);
}
public function testToLargeCreation()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation1200']],
'{"state":"error","msg":"error validate transaction","details":[{"TransactionCreation::validate":"Creation more than 1000 gr per Month not allowed"}]}'
);
}
public function testValidTransfer()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validTransfer']],
['state' => 'success']
);
}
/*public function testMissingPreviousTransaction()
{
}*/
public function testValidTransaction()
{
$this->postAndParse(
['method' => 'putTransaction', 'transaction' => $this->transactions['validCreation']],
['state' => 'success']
);
}
private function postAndParse($params, $expected)
{
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
$this->disableErrorHandlerMiddleware();
$this->post('/TransactionJsonRequestHandler', json_encode($params));
// Check that the response was a 200
$this->assertResponseOk();
$responseBodyString = (string)$this->_response->getBody();
$json = json_decode($responseBodyString);
$this->assertNotFalse($json);
if(is_array($expected)) {
$expected = json_encode($expected);
}
$this->assertEquals($expected, $responseBodyString);
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\UsersController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* App\Controller\UsersController Test Case
*
* @uses \App\Controller\UsersController
*/
class UsersControllerTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.Users',
'app.EmailOptIn',
'app.UserBackups',
'app.UserRoles',
];
/**
* Test index method
*
* @return void
*/
public function testIndex()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test view method
*
* @return void
*/
public function testView()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test add method
*
* @return void
*/
public function testAdd()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test edit method
*
* @return void
*/
public function testEdit()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test delete method
*
* @return void
*/
public function testDelete()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\AdminErrorsTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\AdminErrorsTable Test Case
*/
class AdminErrorsTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\AdminErrorsTable
*/
public $AdminErrors;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.AdminErrors',
'app.StateUsers'
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('AdminErrors') ? [] : ['className' => AdminErrorsTable::class];
$this->AdminErrors = TableRegistry::getTableLocator()->get('AdminErrors', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->AdminErrors);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\ElopageBuysTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\ElopageBuysTable Test Case
*/
class ElopageBuysTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\ElopageBuysTable
*/
public $ElopageBuys;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.ElopageBuys',
'app.ElopageUsers',
'app.AffiliatePrograms',
'app.Publishers',
'app.Orders',
'app.Products',
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('ElopageBuys') ? [] : ['className' => ElopageBuysTable::class];
$this->ElopageBuys = TableRegistry::getTableLocator()->get('ElopageBuys', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->ElopageBuys);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test defaultConnectionName method
*
* @return void
*/
public function testDefaultConnectionName()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\StateErrorsTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\StateErrorsTable Test Case
*/
class StateErrorsTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\StateErrorsTable
*/
public $StateErrors;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.StateErrors',
'app.StateUsers',
'app.TransactionTypes'
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('StateErrors') ? [] : ['className' => StateErrorsTable::class];
$this->StateErrors = TableRegistry::getTableLocator()->get('StateErrors', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->StateErrors);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\StateUsersTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\StateUsersTable Test Case
*/
class StateUsersTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\StateUsersTable
*/
public $StateUsersTable;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.StateUsers',
'app.StateGroups',
'app.StateBalances',
'app.StateCreated',
'app.TransactionCreations',
'app.TransactionSendCoins'
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('StateUsers') ? [] : ['className' => StateUsersTable::class];
$this->StateUsersTable = TableRegistry::getTableLocator()->get('StateUsers', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->StateUsersTable);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test getReceiverProposal method
*
* @return void
*/
public function testGetReceiverProposal()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace App\Test\TestCase\Model\Table;
use App\Model\Table\UsersTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* App\Model\Table\UsersTable Test Case
*/
class UsersTableTest extends TestCase
{
/**
* Test subject
*
* @var \App\Model\Table\UsersTable
*/
public $Users;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'app.Users',
'app.EmailOptIn',
'app.UserBackups',
'app.UserRoles',
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('Users') ? [] : ['className' => UsersTable::class];
$this->Users = TableRegistry::getTableLocator()->get('Users', $config);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
unset($this->Users);
parent::tearDown();
}
/**
* Test initialize method
*
* @return void
*/
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test validationDefault method
*
* @return void
*/
public function testValidationDefault()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test buildRules method
*
* @return void
*/
public function testBuildRules()
{
$this->markTestIncomplete('Not implemented yet.');
}
/**
* Test defaultConnectionName method
*
* @return void
*/
public function testDefaultConnectionName()
{
$this->markTestIncomplete('Not implemented yet.');
}
}

View File

@ -0,0 +1,113 @@
<?php
namespace App\Test\TestCase\Controller;
use App\Controller\AppController;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
use Model\Transactions\TransactionCreation;
/**
* App\Controller\DashboardController Test Case
*
* @uses \App\Controller\DashboardController
*/
class TransactionCreationTest extends TestCase
{
use IntegrationTestTrait;
/**
* Fixtures
*
* @var array
*/
public $fixtures = [
];
public function setUp()
{
parent::setUp();
}
public function testHashingFunction()
{
$pairs = [
"a" => 97,
"b" => 98,
"c" => 99,
"d" => 100,
"aa" => 12513,
"ab" => 12514,
"@" => 64,
".d" => 5988,
"gmx" => 1701624,
"@gmx" => 135919352,
"@gmx.de" => 3742152099,
"***REMOVED***" => 2928827813,
"***REMOVED***" => 1899591683,
"***REMOVED***" => 2089074830,
"maximilian.muster@gradido.net" => 793144931,
"coin-info5@gradido.net" => 1829129963,
"coin-info6@gradido.net" => 1830178539,
"coin-info8@gradido.net" => 1832275691,
"coin-info9@gradido.net" => 1833324267,
"coin-info10@gradido.net" => 3877298078,
"coin-info11@gradido.net" => 3878346654,
"coin-info12@gradido.net" => 3879395230,
"***REMOVED***" => 2089074830,
"***REMOVED***" => 3996757473,
"***REMOVED***" => 3788634614,
"***REMOVED***" => 807797884,
"***REMOVED***" => 1640973721,
"***REMOVED***" => 2025729173,
"***REMOVED***" => 1961122507,
"***REMOVED***" => 362466358,
"***REMOVED***" => 3796728871,
"***REMOVED***" => 807797884,
"***REMOVED***" => 3794905967,
"***REMOVED***" => 3077694284,
"***REMOVED***" => 3246159770,
"***REMOVED***" => 3123402690,
"testneu-11-12-3@gradido.net" => 4092403827,
"***REMOVED***" => 3151414199,
"***REMOVED***" => 3526188273,
"***REMOVED***" => 966804823,
"***REMOVED***" => 1309273258,
"***REMOVED***" => 995978784,
"***REMOVED***" => 310113324,
"***REMOVED***" => 1309273258,
"***REMOVED***" => 530108573,
"***REMOVED***" => 1734855679,
"***REMOVED***" => 767779182,
"***REMOVED***" => 2247491519,
"***REMOVED***" => 3248626267,
"***REMOVED***" => 3516649930,
"***REMOVED***" => 231214190,
"***REMOVED***" => 4247461928,
"***REMOVED***" => 324829839,
"***REMOVED***" => 3046147747,
"***REMOVED***" => 3207307415,
"***REMOVED***" => 728893500,
"***REMOVED***" => 3905254663,
"***REMOVED***" => 3207307415,
"***REMOVED***" => 1155733239,
"***REMOVED***" => 2013046423,
"***REMOVED***" => 4033835283,
"***REMOVED***" => 1945541625,
"***REMOVED***" => 2310715309,
"***REMOVED***" => 1221362064,
"***REMOVED***" => 4161339877
];
foreach($pairs as $email => $cpp_hash) {
$php_hash = TransactionCreation::DRMakeStringHash($email);
// assertEquals(mixed $expected, mixed $actual[, string $message = ''])
if($php_hash != $cpp_hash) {
$this->assertEquals($cpp_hash, $php_hash, "hashes for $email don't match");
}
}
}
}