Skip to content

Commit 16dc550

Browse files
committed
testing
1 parent 98b1a26 commit 16dc550

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

projects/packages/waf/src/class-rest-controller.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ public static function waf() {
110110
*/
111111
public static function update_waf( $request ) {
112112

113-
return rest_ensure_response(
114-
array(
115-
'success' => true,
116-
'message' => 'Test',
117-
)
118-
);
119-
120113
// Automatic Rules Enabled
121114
if ( isset( $request[ Waf_Rules_Manager::AUTOMATIC_RULES_ENABLED_OPTION_NAME ] ) ) {
122115
update_option( Waf_Rules_Manager::AUTOMATIC_RULES_ENABLED_OPTION_NAME, $request->get_param( Waf_Rules_Manager::AUTOMATIC_RULES_ENABLED_OPTION_NAME ) ? '1' : '' );
@@ -189,16 +182,24 @@ public static function update_waf( $request ) {
189182
}
190183
}
191184

192-
// Only attempt to update the WAF if the module is supported
193-
if ( Waf_Runner::is_supported_environment() ) {
194-
try {
195-
Waf_Runner::update_waf();
196-
} catch ( Waf_Exception $e ) {
197-
return $e->get_wp_error();
185+
try {
186+
// Only attempt to update the WAF if the module is supported
187+
if ( Waf_Runner::is_supported_environment() ) {
188+
try {
189+
Waf_Runner::update_waf();
190+
} catch ( Waf_Exception $e ) {
191+
return $e->get_wp_error();
192+
}
198193
}
199-
}
200194

201-
return self::waf();
195+
return self::waf();
196+
} catch ( Waf_Exception $e ) {
197+
return new WP_Error(
198+
'test_waf_failed',
199+
$e->getMessage(),
200+
array( 'status' => 500 )
201+
);
202+
}
202203
}
203204

204205
/**

projects/plugins/protect/tests/e2e/specs/start.test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Plans } from '_jetpack-e2e-commons/env/index.js';
12
import { prerequisitesBuilder } from '_jetpack-e2e-commons/env/prerequisites.js';
23
import { expect, test } from '_jetpack-e2e-commons/fixtures/base-test.js';
34
import logger from '_jetpack-e2e-commons/logger.js';
@@ -40,10 +41,13 @@ test.describe( 'Jetpack Protect plugin - Post-Connection', () => {
4041
test.beforeEach( async ( { page } ) => {
4142
await prerequisitesBuilder( page )
4243
.withCleanEnv()
43-
.withActivePlugins( [ 'protect' ] )
44-
.withInactivePlugins( [ 'e2e-waf-data-interceptor' ] )
44+
.withActivePlugins( [ 'protect', 'jetpack' ] )
45+
.withActiveModules( [ 'waf', 'protect' ] )
46+
// .withInactivePlugins( [ 'e2e-waf-data-interceptor' ] )
4547
.withLoggedIn( true )
4648
.withConnection( true )
49+
.withWpComLoggedIn( true )
50+
.withPlan( Plans.Complete )
4751
.build();
4852
} );
4953

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

56-
await test.step( 'Test the automatic firewall setting is disabled for free plans', async () => {
57-
const automaticFirewallToggle = page.locator( '#inspector-toggle-control-0' );
58-
await expect( automaticFirewallToggle ).toBeDisabled();
59-
await expect( automaticFirewallToggle ).not.toBeChecked();
60-
} );
60+
// await test.step( 'Test the automatic firewall setting is disabled for free plans', async () => {
61+
// const automaticFirewallToggle = page.locator( '#inspector-toggle-control-0' );
62+
// await expect( automaticFirewallToggle ).toBeDisabled();
63+
// await expect( automaticFirewallToggle ).not.toBeChecked();
64+
// } );
6165

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

0 commit comments

Comments
 (0)