by = Operator::factory()->create(); $this->vault = app(SecretVault::class); }); it('does not use the live key while the test mode is active', function () { $this->vault->put('stripe.secret', 'sk_live_real', $this->by, OperatingMode::Live); OperatingMode::set(OperatingMode::Test); expect($this->vault->get('stripe.secret'))->toBeNull(); }); it('does not use the test key while the live mode is active', function () { $this->vault->put('stripe.secret', 'sk_test_fake', $this->by, OperatingMode::Test); OperatingMode::set(OperatingMode::Live); expect($this->vault->get('stripe.secret'))->toBeNull(); }); it('ignores the environment for stripe as well', function () { // Sonst wäre die .env die Hintertür, durch die der Live-Schlüssel doch in // den Testbetrieb kommt. config()->set('services.stripe.secret', 'sk_live_from_env'); OperatingMode::set(OperatingMode::Test); expect($this->vault->get('stripe.secret'))->toBeNull(); }); it('uses the key of the active mode when it is there', function () { $this->vault->put('stripe.secret', 'sk_test_fake', $this->by, OperatingMode::Test); OperatingMode::set(OperatingMode::Test); expect($this->vault->get('stripe.secret'))->toBe('sk_test_fake'); }); it('lets every other entry keep falling back', function () { // Die Ausnahme ist eine Ausnahme, keine neue Regel. $this->vault->put('dns.token', 'live-token', $this->by, OperatingMode::Live); OperatingMode::set(OperatingMode::Test); expect($this->vault->get('dns.token'))->toBe('live-token'); });