Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller committed Mar 8, 2025
1 parent 98b1a26 commit 16dc550
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
31 changes: 16 additions & 15 deletions projects/packages/waf/src/class-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ public static function waf() {
*/
public static function update_waf( $request ) {

return rest_ensure_response(
array(
'success' => true,
'message' => 'Test',
)
);

// Automatic Rules Enabled
if ( isset( $request[ Waf_Rules_Manager::AUTOMATIC_RULES_ENABLED_OPTION_NAME ] ) ) {
update_option( Waf_Rules_Manager::AUTOMATIC_RULES_ENABLED_OPTION_NAME, $request->get_param( Waf_Rules_Manager::AUTOMATIC_RULES_ENABLED_OPTION_NAME ) ? '1' : '' );
Expand Down Expand Up @@ -189,16 +182,24 @@ public static function update_waf( $request ) {
}
}

// Only attempt to update the WAF if the module is supported
if ( Waf_Runner::is_supported_environment() ) {
try {
Waf_Runner::update_waf();
} catch ( Waf_Exception $e ) {
return $e->get_wp_error();
try {
// Only attempt to update the WAF if the module is supported
if ( Waf_Runner::is_supported_environment() ) {
try {
Waf_Runner::update_waf();
} catch ( Waf_Exception $e ) {
return $e->get_wp_error();
}
}
}

return self::waf();
return self::waf();
} catch ( Waf_Exception $e ) {
return new WP_Error(
'test_waf_failed',
$e->getMessage(),
array( 'status' => 500 )
);
}
}

/**
Expand Down
18 changes: 11 additions & 7 deletions projects/plugins/protect/tests/e2e/specs/start.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Plans } from '_jetpack-e2e-commons/env/index.js';
import { prerequisitesBuilder } from '_jetpack-e2e-commons/env/prerequisites.js';
import { expect, test } from '_jetpack-e2e-commons/fixtures/base-test.js';
import logger from '_jetpack-e2e-commons/logger.js';
Expand Down Expand Up @@ -40,10 +41,13 @@ test.describe( 'Jetpack Protect plugin - Post-Connection', () => {
test.beforeEach( async ( { page } ) => {
await prerequisitesBuilder( page )
.withCleanEnv()
.withActivePlugins( [ 'protect' ] )
.withInactivePlugins( [ 'e2e-waf-data-interceptor' ] )
.withActivePlugins( [ 'protect', 'jetpack' ] )
.withActiveModules( [ 'waf', 'protect' ] )
// .withInactivePlugins( [ 'e2e-waf-data-interceptor' ] )
.withLoggedIn( true )
.withConnection( true )
.withWpComLoggedIn( true )
.withPlan( Plans.Complete )
.build();
} );

Expand All @@ -53,11 +57,11 @@ test.describe( 'Jetpack Protect plugin - Post-Connection', () => {
await expect( page.getByText( 'Firewall is on' ) ).toBeVisible();
} );

await test.step( 'Test the automatic firewall setting is disabled for free plans', async () => {
const automaticFirewallToggle = page.locator( '#inspector-toggle-control-0' );
await expect( automaticFirewallToggle ).toBeDisabled();
await expect( automaticFirewallToggle ).not.toBeChecked();
} );
// await test.step( 'Test the automatic firewall setting is disabled for free plans', async () => {
// const automaticFirewallToggle = page.locator( '#inspector-toggle-control-0' );
// await expect( automaticFirewallToggle ).toBeDisabled();
// await expect( automaticFirewallToggle ).not.toBeChecked();
// } );

await test.step( 'Test the brute force protection setting', async () => {
const bruteForceToggle = page.locator( '#inspector-toggle-control-1' );
Expand Down

0 comments on commit 16dc550

Please sign in to comment.