Skip to content

Commit

Permalink
Enhance hCaptcha integration in tests and configuration
Browse files Browse the repository at this point in the history
- Added hCaptcha site and secret keys to phpunit.xml for testing purposes.
- Updated RegisterTest to configure hCaptcha secret key dynamically, ensuring proper token validation in production environment.

These changes improve the testing setup for hCaptcha, facilitating more accurate simulation of production conditions.
  • Loading branch information
JhumanJ committed Dec 18, 2024
1 parent b5f7e2f commit c5b4900
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<env name="JWT_SECRET" value="9K6whOetAFaokQgSIdbMQZuJuDV5uS2Y"/>
<env name="STRIPE_KEY" value="TEST_KEY"/>
<env name="STRIPE_SECRET" value="TEST_SECRET"/>
<env name="H_CAPTCHA_SITE_KEY" value="TEST_SITE_KEY"/>
<env name="H_CAPTCHA_SECRET_KEY" value="TEST_SECRET"/>
</php>
<source>
<include>
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Feature/RegisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
});

it('requires hcaptcha token in production', function () {
app()->detectEnvironment(fn () => 'production');
config(['services.h_captcha.secret_key' => 'test-key']);

Http::fake([
ValidHCaptcha::H_CAPTCHA_VERIFY_URL => Http::response(['success' => true])
Expand Down

0 comments on commit c5b4900

Please sign in to comment.