-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store the api key in the plugin directory
* WordPress SaaS's ABS directory is owned by root, the plugin directory is owned by the WordPress user process. * Move the file on plugin load if it exists, the file should be in the new location. * Fix the docker compose file to allow the volume to have the same permission of my workstation. * Amend tests to include use the new encryption key file.
- Loading branch information
Showing
8 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ vendor/ | |
.idea | ||
|
||
*.phpunit.result.cache | ||
|
||
odoo_conn.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace php\loaded; | ||
require_once __DIR__ . "/../TestClassBrainMonkey.php"; | ||
|
||
use Brain\Monkey\Functions; | ||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; | ||
use org\bovigo\vfs\vfsStream; | ||
use TestClassBrainMonkey; | ||
|
||
class move_existing_encryption_file_test extends TestClassBrainMonkey | ||
{ | ||
|
||
use MockeryPHPUnitIntegration; | ||
|
||
function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (!defined("ABSPATH")) { | ||
define("ABSPATH", "vfs://root/"); | ||
} | ||
Functions\when("plugin_dir_path")->justReturn("vfs://root/plugins/odoo-wp-plugin/"); | ||
|
||
require_once __DIR__ . "/../../../loaded.php"; | ||
|
||
$this->root = vfsStream::setup("root", 0777); | ||
vfsStream::newDirectory("/plugins/odoo-wp-plugin/")->at($this->root); | ||
} | ||
|
||
function test_key_file_moved() | ||
{ | ||
vfsStream::newFile("odoo_conn.key")->at($this->root)->setContent("key"); | ||
|
||
move_existing_encryption_file(); | ||
|
||
$this->assertTrue(file_exists("vfs://root/plugins/odoo-wp-plugin/odoo_conn.key")); | ||
$this->assertFalse(file_exists("vfs://root/odoo_conn.key")); | ||
$this->assertEquals( | ||
"key", $this->root->getChild("plugins/odoo-wp-plugin/odoo_conn.key")->getContent() | ||
); | ||
} | ||
|
||
function test_old_key_file_does_not_exist() | ||
{ | ||
vfsStream::newFile("plugins/odoo-wp-plugin/odoo_conn.key")->at($this->root)->setContent("key"); | ||
|
||
move_existing_encryption_file(); | ||
|
||
$this->assertTrue(file_exists("vfs://root/plugins/odoo-wp-plugin/odoo_conn.key")); | ||
$this->assertFalse(file_exists("vfs://root/odoo_conn.key")); | ||
$this->assertEquals( | ||
"key", $this->root->getChild("plugins/odoo-wp-plugin/odoo_conn.key")->getContent() | ||
); | ||
} | ||
|
||
} | ||
|
||
?> |