diff --git a/.gitmodules b/.gitmodules index 88a463730..16b05784f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "mithril_client"] path = mithril_client url = ssh://git@***REMOVED***/~/_mithril/gradido_mithrilJS_client +[submodule "src/protobuf"] + path = src/protobuf + url = ssh://git@***REMOVED***/~/_protobuf/gradido_protobuf diff --git a/composer.json b/composer.json index 0f6ba320a..3c5ff0d58 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "cakephp/cakephp-codesniffer": "^3.0", "cakephp/debug_kit": "^3.17.0", "josegonzalez/dotenv": "3.*", - "phpunit/phpunit": "^5|^6", + "phpunit/phpunit": "^5.7|^6.0", "psy/psysh": "@stable" }, "suggest": { diff --git a/composer.lock b/composer.lock index 8f7349d0c..8b7e5aa5a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "2944d37824c58c80f9759fff3074fa2d", + "content-hash": "de9b091bfb2ef9e30a63a154a97b5d9f", "packages": [ { "name": "aura/intl", diff --git a/mithril_client b/mithril_client index 680e56876..f0b1d113c 160000 --- a/mithril_client +++ b/mithril_client @@ -1 +1 @@ -Subproject commit 680e56876d6e7f2778bff4eb49c880063716b391 +Subproject commit f0b1d113cee2a76e9dbb098b315f4acaf38410d0 diff --git a/src/Controller/TransactionCreationsController.php b/src/Controller/TransactionCreationsController.php index 5e312b4e7..245e3eb21 100644 --- a/src/Controller/TransactionCreationsController.php +++ b/src/Controller/TransactionCreationsController.php @@ -13,6 +13,7 @@ use App\Form\CreationForm; use Model\Messages\Gradido\TransactionCreation; use Model\Messages\Gradido\TransactionBody; use Model\Messages\Gradido\ReceiverAmount; +use Model\Messages\Gradido\TimestampSeconds; /** * TransactionCreations Controller * @@ -120,9 +121,14 @@ class TransactionCreationsController extends AppController if($pubKeyHex != '') { $receiver->setEd25519ReceiverPubkey(hex2bin($pubKeyHex)); //var_dump($requestData); + + $creationDate = new TimestampSeconds(); + $creationDate->setSeconds(time()); + $transactionBody = new TransactionBody(); $transactionBody->setMemo($requestData['memo']); - + $transactionBody->setCreated($creationDate); + $transaction = new TransactionCreation(); $transaction->setReceiverAmount($receiver); $transaction->setIdentHash($user['ident_hash']); diff --git a/src/Model/Messages/Gradido/Key.php b/src/Model/Messages/Gradido/Key.php index b6190304c..ace440729 100644 --- a/src/Model/Messages/Gradido/Key.php +++ b/src/Model/Messages/Gradido/Key.php @@ -22,9 +22,9 @@ class Key extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $ed25519 - * ed25519 signature (libsodium default) + * ed25519 signature (libsodium default) * @type string $ed25519_ref10 - * ed25519 ref10 signature + * ed25519 ref10 signature * } */ public function __construct($data = NULL) { @@ -33,7 +33,7 @@ class Key extends \Google\Protobuf\Internal\Message } /** - * ed25519 signature (libsodium default) + * ed25519 signature (libsodium default) * * Generated from protobuf field bytes ed25519 = 2; * @return string @@ -44,7 +44,7 @@ class Key extends \Google\Protobuf\Internal\Message } /** - * ed25519 signature (libsodium default) + * ed25519 signature (libsodium default) * * Generated from protobuf field bytes ed25519 = 2; * @param string $var @@ -59,7 +59,7 @@ class Key extends \Google\Protobuf\Internal\Message } /** - * ed25519 ref10 signature + * ed25519 ref10 signature * * Generated from protobuf field bytes ed25519_ref10 = 3; * @return string @@ -70,7 +70,7 @@ class Key extends \Google\Protobuf\Internal\Message } /** - * ed25519 ref10 signature + * ed25519 ref10 signature * * Generated from protobuf field bytes ed25519_ref10 = 3; * @param string $var diff --git a/src/Model/Messages/Gradido/SenderAmount.php b/src/Model/Messages/Gradido/SenderAmount.php index 52a41f71f..9b423947e 100644 --- a/src/Model/Messages/Gradido/SenderAmount.php +++ b/src/Model/Messages/Gradido/SenderAmount.php @@ -22,7 +22,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message */ private $amount = 0; /** - * sender balance after transaction, including perishability + * sender balance after transaction, including perishability * * Generated from protobuf field sint64 senderFinalBalance = 3; */ @@ -37,7 +37,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message * @type string $ed25519_sender_pubkey * @type int|string $amount * @type int|string $senderFinalBalance - * sender balance after transaction, including perishability + * sender balance after transaction, including perishability * } */ public function __construct($data = NULL) { @@ -90,7 +90,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message } /** - * sender balance after transaction, including perishability + * sender balance after transaction, including perishability * * Generated from protobuf field sint64 senderFinalBalance = 3; * @return int|string @@ -101,7 +101,7 @@ class SenderAmount extends \Google\Protobuf\Internal\Message } /** - * sender balance after transaction, including perishability + * sender balance after transaction, including perishability * * Generated from protobuf field sint64 senderFinalBalance = 3; * @param int|string $var diff --git a/src/Model/Messages/Gradido/SignatureMap.php b/src/Model/Messages/Gradido/SignatureMap.php index 228282747..ea6f16150 100644 --- a/src/Model/Messages/Gradido/SignatureMap.php +++ b/src/Model/Messages/Gradido/SignatureMap.php @@ -14,7 +14,7 @@ use Google\Protobuf\Internal\GPBUtil; class SignatureMap extends \Google\Protobuf\Internal\Message { /** - * Each signature pair corresponds to a unique Key required to sign the transaction. + * Each signature pair corresponds to a unique Key required to sign the transaction. * * Generated from protobuf field repeated .model.messages.gradido.SignaturePair sigPair = 1; */ @@ -27,7 +27,7 @@ class SignatureMap extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type \Model\Messages\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $sigPair - * Each signature pair corresponds to a unique Key required to sign the transaction. + * Each signature pair corresponds to a unique Key required to sign the transaction. * } */ public function __construct($data = NULL) { @@ -36,7 +36,7 @@ class SignatureMap extends \Google\Protobuf\Internal\Message } /** - * Each signature pair corresponds to a unique Key required to sign the transaction. + * Each signature pair corresponds to a unique Key required to sign the transaction. * * Generated from protobuf field repeated .model.messages.gradido.SignaturePair sigPair = 1; * @return \Google\Protobuf\Internal\RepeatedField @@ -47,7 +47,7 @@ class SignatureMap extends \Google\Protobuf\Internal\Message } /** - * Each signature pair corresponds to a unique Key required to sign the transaction. + * Each signature pair corresponds to a unique Key required to sign the transaction. * * Generated from protobuf field repeated .model.messages.gradido.SignaturePair sigPair = 1; * @param \Model\Messages\Gradido\SignaturePair[]|\Google\Protobuf\Internal\RepeatedField $var diff --git a/src/Model/Messages/Gradido/SignaturePair.php b/src/Model/Messages/Gradido/SignaturePair.php index 203eb5677..4575a7d38 100644 --- a/src/Model/Messages/Gradido/SignaturePair.php +++ b/src/Model/Messages/Gradido/SignaturePair.php @@ -27,9 +27,9 @@ class SignaturePair extends \Google\Protobuf\Internal\Message * * @type string $pubKey * @type string $ed25519 - * ed25519 signature (libsodium default) + * ed25519 signature (libsodium default) * @type string $ed25519_ref10 - * ed25519 ref10 signature + * ed25519 ref10 signature * } */ public function __construct($data = NULL) { @@ -60,7 +60,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message } /** - * ed25519 signature (libsodium default) + * ed25519 signature (libsodium default) * * Generated from protobuf field bytes ed25519 = 2; * @return string @@ -71,7 +71,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message } /** - * ed25519 signature (libsodium default) + * ed25519 signature (libsodium default) * * Generated from protobuf field bytes ed25519 = 2; * @param string $var @@ -86,7 +86,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message } /** - * ed25519 ref10 signature + * ed25519 ref10 signature * * Generated from protobuf field bytes ed25519_ref10 = 3; * @return string @@ -97,7 +97,7 @@ class SignaturePair extends \Google\Protobuf\Internal\Message } /** - * ed25519 ref10 signature + * ed25519 ref10 signature * * Generated from protobuf field bytes ed25519_ref10 = 3; * @param string $var diff --git a/src/Model/Messages/Gradido/StateCreateGroup.php b/src/Model/Messages/Gradido/StateCreateGroup.php index 4273ef93d..dad246745 100644 --- a/src/Model/Messages/Gradido/StateCreateGroup.php +++ b/src/Model/Messages/Gradido/StateCreateGroup.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * need signature from this group and from parent (if it isn't zero) + * need signature from this group and from parent (if it isn't zero) * * Generated from protobuf message model.messages.gradido.StateCreateGroup */ diff --git a/src/Model/Messages/Gradido/StateGroupChangeParent.php b/src/Model/Messages/Gradido/StateGroupChangeParent.php index c5371d76c..9cd15175a 100644 --- a/src/Model/Messages/Gradido/StateGroupChangeParent.php +++ b/src/Model/Messages/Gradido/StateGroupChangeParent.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * need signature from this group and from both parents (if it isn't zero) + * need signature from this group and from both parents (if it isn't zero) * * Generated from protobuf message model.messages.gradido.StateGroupChangeParent */ diff --git a/src/Model/Messages/Gradido/Timestamp.php b/src/Model/Messages/Gradido/Timestamp.php index 19721729b..7b2316720 100644 --- a/src/Model/Messages/Gradido/Timestamp.php +++ b/src/Model/Messages/Gradido/Timestamp.php @@ -16,13 +16,13 @@ use Google\Protobuf\Internal\GPBUtil; class Timestamp extends \Google\Protobuf\Internal\Message { /** - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * * Generated from protobuf field int64 seconds = 1; */ private $seconds = 0; /** - * Number of nanoseconds since the start of the last second + * Number of nanoseconds since the start of the last second * * Generated from protobuf field int32 nanos = 2; */ @@ -35,9 +35,9 @@ class Timestamp extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type int|string $seconds - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * @type int $nanos - * Number of nanoseconds since the start of the last second + * Number of nanoseconds since the start of the last second * } */ public function __construct($data = NULL) { @@ -46,7 +46,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message } /** - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * * Generated from protobuf field int64 seconds = 1; * @return int|string @@ -57,7 +57,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message } /** - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * * Generated from protobuf field int64 seconds = 1; * @param int|string $var @@ -72,7 +72,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message } /** - * Number of nanoseconds since the start of the last second + * Number of nanoseconds since the start of the last second * * Generated from protobuf field int32 nanos = 2; * @return int @@ -83,7 +83,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message } /** - * Number of nanoseconds since the start of the last second + * Number of nanoseconds since the start of the last second * * Generated from protobuf field int32 nanos = 2; * @param int $var diff --git a/src/Model/Messages/Gradido/TimestampSeconds.php b/src/Model/Messages/Gradido/TimestampSeconds.php index 2a588a312..2646a06c9 100644 --- a/src/Model/Messages/Gradido/TimestampSeconds.php +++ b/src/Model/Messages/Gradido/TimestampSeconds.php @@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil; class TimestampSeconds extends \Google\Protobuf\Internal\Message { /** - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * * Generated from protobuf field int64 seconds = 1; */ @@ -29,7 +29,7 @@ class TimestampSeconds extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type int|string $seconds - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * } */ public function __construct($data = NULL) { @@ -38,7 +38,7 @@ class TimestampSeconds extends \Google\Protobuf\Internal\Message } /** - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * * Generated from protobuf field int64 seconds = 1; * @return int|string @@ -49,7 +49,7 @@ class TimestampSeconds extends \Google\Protobuf\Internal\Message } /** - * Number of complete seconds since the start of the epoch + * Number of complete seconds since the start of the epoch * * Generated from protobuf field int64 seconds = 1; * @param int|string $var diff --git a/src/Model/Messages/Gradido/TransactionBody.php b/src/Model/Messages/Gradido/TransactionBody.php index 0b8b05005..3452d4251 100644 --- a/src/Model/Messages/Gradido/TransactionBody.php +++ b/src/Model/Messages/Gradido/TransactionBody.php @@ -19,6 +19,10 @@ class TransactionBody extends \Google\Protobuf\Internal\Message * Generated from protobuf field string memo = 1; */ private $memo = ''; + /** + * Generated from protobuf field .model.messages.gradido.TimestampSeconds created = 2; + */ + private $created = null; protected $data; /** @@ -29,6 +33,7 @@ class TransactionBody extends \Google\Protobuf\Internal\Message * * @type string $memo * max 150 chars + * @type \Model\Messages\Gradido\TimestampSeconds $created * @type \Model\Messages\Gradido\StateCreateGroup $createGroup * @type \Model\Messages\Gradido\StateGroupChangeParent $groupChangeParent * @type \Model\Messages\Gradido\Transfer $transfer @@ -67,89 +72,111 @@ class TransactionBody extends \Google\Protobuf\Internal\Message } /** - * Generated from protobuf field .model.messages.gradido.StateCreateGroup createGroup = 2; + * Generated from protobuf field .model.messages.gradido.TimestampSeconds created = 2; + * @return \Model\Messages\Gradido\TimestampSeconds + */ + public function getCreated() + { + return $this->created; + } + + /** + * Generated from protobuf field .model.messages.gradido.TimestampSeconds created = 2; + * @param \Model\Messages\Gradido\TimestampSeconds $var + * @return $this + */ + public function setCreated($var) + { + GPBUtil::checkMessage($var, \Model\Messages\Gradido\TimestampSeconds::class); + $this->created = $var; + + return $this; + } + + /** + * Generated from protobuf field .model.messages.gradido.StateCreateGroup createGroup = 6; * @return \Model\Messages\Gradido\StateCreateGroup */ public function getCreateGroup() { - return $this->readOneof(2); + return $this->readOneof(6); } /** - * Generated from protobuf field .model.messages.gradido.StateCreateGroup createGroup = 2; + * Generated from protobuf field .model.messages.gradido.StateCreateGroup createGroup = 6; * @param \Model\Messages\Gradido\StateCreateGroup $var * @return $this */ public function setCreateGroup($var) { GPBUtil::checkMessage($var, \Model\Messages\Gradido\StateCreateGroup::class); - $this->writeOneof(2, $var); + $this->writeOneof(6, $var); return $this; } /** - * Generated from protobuf field .model.messages.gradido.StateGroupChangeParent groupChangeParent = 3; + * Generated from protobuf field .model.messages.gradido.StateGroupChangeParent groupChangeParent = 7; * @return \Model\Messages\Gradido\StateGroupChangeParent */ public function getGroupChangeParent() { - return $this->readOneof(3); + return $this->readOneof(7); } /** - * Generated from protobuf field .model.messages.gradido.StateGroupChangeParent groupChangeParent = 3; + * Generated from protobuf field .model.messages.gradido.StateGroupChangeParent groupChangeParent = 7; * @param \Model\Messages\Gradido\StateGroupChangeParent $var * @return $this */ public function setGroupChangeParent($var) { GPBUtil::checkMessage($var, \Model\Messages\Gradido\StateGroupChangeParent::class); - $this->writeOneof(3, $var); + $this->writeOneof(7, $var); return $this; } /** - * Generated from protobuf field .model.messages.gradido.Transfer transfer = 4; + * Generated from protobuf field .model.messages.gradido.Transfer transfer = 8; * @return \Model\Messages\Gradido\Transfer */ public function getTransfer() { - return $this->readOneof(4); + return $this->readOneof(8); } /** - * Generated from protobuf field .model.messages.gradido.Transfer transfer = 4; + * Generated from protobuf field .model.messages.gradido.Transfer transfer = 8; * @param \Model\Messages\Gradido\Transfer $var * @return $this */ public function setTransfer($var) { GPBUtil::checkMessage($var, \Model\Messages\Gradido\Transfer::class); - $this->writeOneof(4, $var); + $this->writeOneof(8, $var); return $this; } /** - * Generated from protobuf field .model.messages.gradido.TransactionCreation creation = 5; + * Generated from protobuf field .model.messages.gradido.TransactionCreation creation = 9; * @return \Model\Messages\Gradido\TransactionCreation */ public function getCreation() { - return $this->readOneof(5); + return $this->readOneof(9); } /** - * Generated from protobuf field .model.messages.gradido.TransactionCreation creation = 5; + * Generated from protobuf field .model.messages.gradido.TransactionCreation creation = 9; * @param \Model\Messages\Gradido\TransactionCreation $var * @return $this */ public function setCreation($var) { GPBUtil::checkMessage($var, \Model\Messages\Gradido\TransactionCreation::class); - $this->writeOneof(5, $var); + $this->writeOneof(9, $var); return $this; } diff --git a/src/Model/Messages/Gradido/TransactionCreation.php b/src/Model/Messages/Gradido/TransactionCreation.php index 0673cf9b9..46c5eaa09 100644 --- a/src/Model/Messages/Gradido/TransactionCreation.php +++ b/src/Model/Messages/Gradido/TransactionCreation.php @@ -9,8 +9,8 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * need signature from group admin or - * percent of group users another than the receiver + * need signature from group admin or + * percent of group users another than the receiver * * Generated from protobuf message model.messages.gradido.TransactionCreation */ diff --git a/src/Model/Transactions/Transaction.php b/src/Model/Transactions/Transaction.php index eae0546fc..64088f55b 100644 --- a/src/Model/Transactions/Transaction.php +++ b/src/Model/Transactions/Transaction.php @@ -1,3 +1,4 @@ +<<<<<<< HEAD addError('base64 decode failed'); + $this->addError(['data' => $base64Data, 'bin' => $transactionBin, 'msg' => 'base64 decode error']); + } else { + $this->mProtoTransaction = new \Model\Messages\Gradido\Transaction(); + $this->mProtoTransaction->mergeFromString($transactionBin); + + $this->mProtoTransactionBody = new \Model\Messages\Gradido\TransactionBody(); + $this->mProtoTransactionBody->mergeFromString($this->mProtoTransaction->getBodyBytes()); + + $data = $this->mProtoTransactionBody->getData(); + var_dump($data); + } + } + + public function validate() { + $sigPairs = $this->mProtoTransaction->getSigMap()->getSigPair(); + $bodyBytes = $this->mProtoTransaction->getBodyBytes(); + + // check signature(s) + foreach($sigPairs as $sigPair) { + $pubkey = $sigPair->getPubKey(); + $signature = $sigPair->getEd25519(); + if (!\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) { + $this->addError('signature for key ' . bin2hex($pubkey) . ' isn\'t valid ' ); + return false; + } + } + + return true; + } + + public function getErrors() { + return $this->errors; + } + + public function hasErrors() { + return count($this->errors) > 0; + } + + + private function addError($message) { + array_push($this->errors, $message); + } +>>>>>>> bcb8f1761e3eb94f89e9d2c4e70ab096e528e6c6 } \ No newline at end of file diff --git a/src/Model/Transactions/TransactionBase.php b/src/Model/Transactions/TransactionBase.php index e8f299216..b0df59d14 100644 --- a/src/Model/Transactions/TransactionBase.php +++ b/src/Model/Transactions/TransactionBase.php @@ -1,3 +1,4 @@ +<<<<<<< HEAD >>>>>> bcb8f1761e3eb94f89e9d2c4e70ab096e528e6c6 } \ No newline at end of file diff --git a/src/Model/Transactions/TransactionBody.php b/src/Model/Transactions/TransactionBody.php index 943e46dc8..98120b28d 100644 --- a/src/Model/Transactions/TransactionBody.php +++ b/src/Model/Transactions/TransactionBody.php @@ -19,6 +19,11 @@ class TransactionBody extends TransactionBase { } public function validate($sigPairs) { + // check if creation time is in the past + if($this->mProtoTransactionBody->getCreated() > time()) { + $this->addError('TransactionBody::validate', 'Transaction were created in the past!'); + return false; + } if(!$this->mSpecificTransaction->validate($sigPairs)) { $this->addErrors($this->mSpecificTransaction->getErrors()); return false; diff --git a/src/protobuf b/src/protobuf new file mode 160000 index 000000000..77e878253 --- /dev/null +++ b/src/protobuf @@ -0,0 +1 @@ +Subproject commit 77e878253ac2a044eb59700386c961c812667eae diff --git a/tests/Fixture/StateBalancesFixture.php b/tests/Fixture/StateBalancesFixture.php new file mode 100644 index 000000000..1fb80f37c --- /dev/null +++ b/tests/Fixture/StateBalancesFixture.php @@ -0,0 +1,48 @@ + ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'user_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'modified' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'amount' => ['type' => 'biginteger', 'length' => 20, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => 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, + 'user_id' => 1, + 'modified' => '2019-11-05 18:02:28', + 'amount' => 1 + ], + ]; + parent::init(); + } +} diff --git a/tests/Fixture/StateUsersFixture.php b/tests/Fixture/StateUsersFixture.php new file mode 100644 index 000000000..de633e816 --- /dev/null +++ b/tests/Fixture/StateUsersFixture.php @@ -0,0 +1,55 @@ + ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'index_id' => ['type' => 'smallinteger', 'length' => 6, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'group_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'public_key' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'email' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null], + 'first_name' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null], + 'last_name' => ['type' => 'string', 'length' => 255, 'null' => true, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null], + '_constraints' => [ + 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []], + 'public_key' => ['type' => 'unique', 'columns' => ['public_key'], 'length' => []], + ], + '_options' => [ + 'engine' => 'InnoDB', + 'collation' => 'utf8_bin' + ], + ]; + // @codingStandardsIgnoreEnd + /** + * Init method + * + * @return void + */ + public function init() + { + $this->records = [ + [ + 'id' => 1, + 'index_id' => 1, + 'group_id' => 1, + 'public_key' => 'Lorem ipsum dolor sit amet', + 'email' => 'Lorem ipsum dolor sit amet', + 'first_name' => 'Lorem ipsum dolor sit amet', + 'last_name' => 'Lorem ipsum dolor sit amet' + ], + ]; + parent::init(); + } +} diff --git a/tests/Fixture/TransactionCreationsFixture.php b/tests/Fixture/TransactionCreationsFixture.php new file mode 100644 index 000000000..8717d0cc5 --- /dev/null +++ b/tests/Fixture/TransactionCreationsFixture.php @@ -0,0 +1,50 @@ + ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'transaction_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'state_user_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'amount' => ['type' => 'biginteger', 'length' => 20, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'ident_hash' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => 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, + 'transaction_id' => 1, + 'state_user_id' => 1, + 'amount' => 1, + 'ident_hash' => 'Lorem ipsum dolor sit amet' + ], + ]; + parent::init(); + } +} diff --git a/tests/Fixture/TransactionSendCoinsFixture.php b/tests/Fixture/TransactionSendCoinsFixture.php new file mode 100644 index 000000000..38c0af9f4 --- /dev/null +++ b/tests/Fixture/TransactionSendCoinsFixture.php @@ -0,0 +1,54 @@ + ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'transaction_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'state_user_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'receiver_public_key' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'receiver_user_id' => ['type' => 'binary', 'length' => 64, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'amount' => ['type' => 'biginteger', 'length' => 20, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'sender_final_balance' => ['type' => 'biginteger', 'length' => 20, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => 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, + 'transaction_id' => 1, + 'state_user_id' => 1, + 'receiver_public_key' => 'Lorem ipsum dolor sit amet', + 'receiver_user_id' => 'Lorem ipsum dolor sit amet', + 'amount' => 1, + 'sender_final_balance' => 1 + ], + ]; + parent::init(); + } +} diff --git a/tests/Fixture/TransactionSignaturesFixture.php b/tests/Fixture/TransactionSignaturesFixture.php new file mode 100644 index 000000000..2ce9e0a41 --- /dev/null +++ b/tests/Fixture/TransactionSignaturesFixture.php @@ -0,0 +1,48 @@ + ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'transaction_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'signature' => ['type' => 'binary', 'length' => 64, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'pubkey' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => 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, + 'transaction_id' => 1, + 'signature' => 'Lorem ipsum dolor sit amet', + 'pubkey' => 'Lorem ipsum dolor sit amet' + ], + ]; + parent::init(); + } +} diff --git a/tests/Fixture/TransactionTypesFixture.php b/tests/Fixture/TransactionTypesFixture.php new file mode 100644 index 000000000..2edcd645e --- /dev/null +++ b/tests/Fixture/TransactionTypesFixture.php @@ -0,0 +1,51 @@ + ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'name' => ['type' => 'string', 'length' => 24, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null], + 'text' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', '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, + 'name' => 'creation', + 'text' => 'Aktives oder Bedingsungsloses Grundeinkommen' + ], + [ + 'id' => 2, + 'name' => 'transfer', + 'text' => 'Einfache Überweisung' + ] + ]; + parent::init(); + } +} diff --git a/tests/Fixture/TransactionsFixture.php b/tests/Fixture/TransactionsFixture.php new file mode 100644 index 000000000..0c4378ba7 --- /dev/null +++ b/tests/Fixture/TransactionsFixture.php @@ -0,0 +1,52 @@ + ['type' => 'biginteger', 'length' => 20, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'group_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'transaction_type_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'tx_hash' => ['type' => 'binary', 'length' => 32, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'memo' => ['type' => 'string', 'length' => 255, 'null' => false, 'default' => null, 'collate' => 'utf8_bin', 'comment' => '', 'precision' => null, 'fixed' => null], + 'received' => ['type' => 'timestamp', 'length' => null, 'null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '', 'precision' => 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, + 'group_id' => 1, + 'transaction_type_id' => 1, + 'tx_hash' => 'Lorem ipsum dolor sit amet', + 'memo' => 'Lorem ipsum dolor sit amet', + 'received' => 1572973566 + ], + ]; + parent::init(); + } +} diff --git a/tests/TestCase/Controller/DashboardControllerTest.php b/tests/TestCase/Controller/DashboardControllerTest.php new file mode 100644 index 000000000..cddf0b7ef --- /dev/null +++ b/tests/TestCase/Controller/DashboardControllerTest.php @@ -0,0 +1,45 @@ +markTestIncomplete('Not implemented yet.'); + } + + /** + * Test index method + * + * @return void + */ + public function testIndex() + { + $this->markTestIncomplete('Not implemented yet.'); + } +} diff --git a/tests/TestCase/Controller/PagesControllerTest.php b/tests/TestCase/Controller/PagesControllerTest.php index 11b8b1db5..35fe1a13b 100644 --- a/tests/TestCase/Controller/PagesControllerTest.php +++ b/tests/TestCase/Controller/PagesControllerTest.php @@ -35,9 +35,9 @@ class PagesControllerTest extends IntegrationTestCase public function testMultipleGet() { $this->get('/'); - $this->assertResponseOk(); + $this->assertRedirect('account/'); $this->get('/'); - $this->assertResponseOk(); + $this->assertRedirect('account/'); } /** diff --git a/tests/TestCase/Controller/TransactionCreationsControllerTest.php b/tests/TestCase/Controller/TransactionCreationsControllerTest.php new file mode 100644 index 000000000..74c0e4b1e --- /dev/null +++ b/tests/TestCase/Controller/TransactionCreationsControllerTest.php @@ -0,0 +1,97 @@ +markTestIncomplete('Not implemented yet.'); + } + + /** + * 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 create method + * + * @return void + */ + public function testCreate() + { + $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.'); + } +} diff --git a/tests/TestCase/Controller/TransactionJsonRequestHandlerControllerTest.php b/tests/TestCase/Controller/TransactionJsonRequestHandlerControllerTest.php new file mode 100644 index 000000000..147154c4e --- /dev/null +++ b/tests/TestCase/Controller/TransactionJsonRequestHandlerControllerTest.php @@ -0,0 +1,52 @@ +markTestIncomplete('Not implemented yet.'); + } + + /** + * Test index method + * + * @return void + */ + public function testIndex() + { + //$this->markTestIncomplete('Not implemented yet.'); + $this->post('/TransactionJsonRequestHandler', ['method' => 'putTransaction', 'transaction' => 'CgpIYWxsbyBXZWx0EgYIyfSG7gVKLwonCiCboKikqwjZfes9xuqgthFH3/cHHaWchkUhWiGhQjB23xCg2pMBELWJ7ZYK']); + } +}