genecommerce / module-encryption-key-manager

Tooling to help generate and invalidate magento encryption keys
GNU Lesser General Public License v3.0
54 stars 14 forks source link

Add basic circleci verification tests #16

Closed convenient closed 1 month ago

convenient commented 1 month ago

The test output looks like

Stubbing in some test data
n98-magerun2 7.4.0 (commit: 94ac790) by netz98 GmbH
Created Magento administrator user named adminuser1721235458
zzzzz/zzzzz/zzzz => abc123
Generated FAKE_RP_TOKEN=0:3:AR2pYVCIxMiTlRxVcSdzXCjS7O43Mk0B/Xpn+otnDEmOaA== and assigned to adminuser1721235458

Verifying commands need to use --force
PASS: generate needs to run with force
PASS: invalidate needs to run with force
PASS: reencrypt-column needs to run with force

Verifying you cannot invalidate with only 1 key
PASS: You cannot invalidate with only 1 key

Generating a new encryption key
The system currently has 1 keys
Generating a new encryption key using the magento core class
_reEncryptSystemConfigurationValues - start
_reEncryptSystemConfigurationValues - end
_reEncryptCreditCardNumbers - start
_reEncryptCreditCardNumbers - end
Cleaning cache
Done
PASS

Running reencrypt-unhandled-core-config-data
The latest encryption key is number 1, looking for old entries
########################################################################################################################
config_id: 20
scope: default
scope_id: 0
path: zzzzz/zzzzz/zzzz
updated_at: 2024-07-17 16:57:40
ciphertext_old: 0:3:R5NQfKdGhZselSV6klpS8x9htPdoHr5dzbva3K9tUGtqqw==
plaintext: abc123
ciphertext_new: 1:3:O3qR0ciI+wIPWcVMqJ2oXhLCf5rpnP96AD8QBg/RHfnzmQ==
########################################################################################################################
Done
PASS

Running reencrypt-unhandled-core-config-data - again to verify it was all processed
The latest encryption key is number 1, looking for old entries
No old entries found
PASS

Running reencrypt-column
The latest encryption key is number 1, looking for old entries
Looking for 'rp_token' in 'admin_user', identified by 'user_id'
########################################################################################################################
user_id: 2
ciphertext_old: 0:3:AR2pYVCIxMiTlRxVcSdzXCjS7O43Mk0B/Xpn+otnDEmOaA==
plaintext: abc123
ciphertext_new: 1:3:yqPhOn7X3mZxwX2cXj6G3x34ZbxpoLYcrfsuSQcC6fyV1A==
########################################################################################################################
Done
PASS

Running reencrypt-column - again to verify it was all processed
The latest encryption key is number 1, looking for old entries
Looking for 'rp_token' in 'admin_user', identified by 'user_id'
No old entries found
PASS

Running invalidate
Writing crypt/invalidated_key to env.php
Writing crypt/key to env.php
Done
No further keys need invalidated
PASS

A peek at the env.php
    'crypt' => [
        'key' => 'geneinvalidatedkeys6697f80b9c1fd
11504abc0ec29e100bc35e948441798c',
        'invalidated_key' => '122f8f026785a339a8c425fa29bee852'
    ],
    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'database',
                'dbname' => 'magento',
DONE