DotenvVault example

class SecretsListCommandTest extends TestCase
{
    /** * @backupGlobals enabled */
    public function testExecute()
    {
        $vault = $this->createMock(AbstractVault::class);
        $vault->method('list')->willReturn(['A' => 'a', 'B' => 'b', 'C' => null, 'D' => null, 'E' => null]);

        $_ENV = ['A' => '', 'B' => 'A', 'C' => '', 'D' => false, 'E' => null];
        $localVault = new DotenvVault('/not/a/path');

        $command = new SecretsListCommand($vault$localVault);
        $tester = new CommandTester($command);
        $this->assertSame(0, $tester->execute([]));

        $expectedOutput = <<<EOTXT // Use "%%env(<name>)%%" to reference a secret in a config file. // To reveal the secrets run %s secrets:list --reveal -------- -------- ------------- Secret Value Local Value -------- -------- ------------- A "a" B "b" ****** C ****** D ****** ****** E ****** -------- -------- ------------- // Local values override secret values. // Use secrets:set --local to define them.
$this->envFile = sys_get_temp_dir().'/sf_secrets.env.test';
        @unlink($this->envFile);
    }

    protected function tearDown(): void
    {
        @unlink($this->envFile);
    }

    public function testGenerateKeys()
    {
        $vault = new DotenvVault($this->envFile);

        $this->assertFalse($vault->generateKeys());
        $this->assertSame('The dotenv vault doesn\'t encrypt secrets thus doesn\'t need keys.', $vault->getLastMessage());
    }

    public function testEncryptAndDecrypt()
    {
        $vault = new DotenvVault($this->envFile);

        $plain = "plain\ntext";

        
Home | Imprint | This part of the site doesn't use cookies.