This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-wss4j.git
The following commit(s) were added to refs/heads/master by this push:
new 46c3a8f1f Fail negative policy tests when nothing throws (#770)
46c3a8f1f is described below
commit 46c3a8f1ffa766371e0d95bdffc7ee886428cdbd
Author: Sharang Gupta <[email protected]>
AuthorDate: Thu Nov 5 11:23:15 2026 +0000
Fail negative policy tests when nothing throws (#770)
Six negative tests in EncryptedPartsTest, SignedPartsTest and
TokenProtectionTest checked the policy violation only in the catch
block, so they passed if the enforcer accepted the message. Add the
fail() their sibling tests already have.
---
.../java/org/apache/wss4j/policy/stax/test/EncryptedPartsTest.java | 1 +
.../test/java/org/apache/wss4j/policy/stax/test/SignedPartsTest.java | 1 +
.../java/org/apache/wss4j/policy/stax/test/TokenProtectionTest.java | 4 ++++
3 files changed, 6 insertions(+)
diff --git
a/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/EncryptedPartsTest.java
b/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/EncryptedPartsTest.java
index 7d197d55e..c7bdd9a18 100644
---
a/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/EncryptedPartsTest.java
+++
b/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/EncryptedPartsTest.java
@@ -154,6 +154,7 @@ public class EncryptedPartsTest extends
AbstractPolicyTestBase {
encryptedPartSecurityEvent.setElementPath(WSSConstants.SOAP_11_BODY_PATH);
try {
policyEnforcer.registerSecurityEvent(encryptedPartSecurityEvent);
+ fail("Exception expected");
} catch (WSSecurityException e) {
assertTrue(e.getCause() instanceof PolicyViolationException);
assertEquals(e.getCause().getMessage(),
diff --git
a/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SignedPartsTest.java
b/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SignedPartsTest.java
index 6dd4b9176..915a5eba1 100644
---
a/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SignedPartsTest.java
+++
b/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SignedPartsTest.java
@@ -160,6 +160,7 @@ public class SignedPartsTest extends AbstractPolicyTestBase
{
signedPartSecurityEvent.setElementPath(WSSConstants.SOAP_11_BODY_PATH);
try {
policyEnforcer.registerSecurityEvent(signedPartSecurityEvent);
+ fail("Exception expected");
} catch (WSSecurityException e) {
assertTrue(e.getCause() instanceof PolicyViolationException);
assertEquals(e.getCause().getMessage(),
diff --git
a/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TokenProtectionTest.java
b/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TokenProtectionTest.java
index c984aa153..86f3434a2 100644
---
a/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TokenProtectionTest.java
+++
b/ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TokenProtectionTest.java
@@ -216,6 +216,7 @@ public class TokenProtectionTest extends
AbstractPolicyTestBase {
operationSecurityEvent.setOperation(WSDL_DEFINITIONS);
try {
policyEnforcer.registerSecurityEvent(operationSecurityEvent);
+ fail("Exception expected");
} catch (WSSecurityException e) {
assertTrue(e.getCause() instanceof PolicyViolationException);
assertEquals(e.getCause().getMessage(),
@@ -431,6 +432,7 @@ public class TokenProtectionTest extends
AbstractPolicyTestBase {
operationSecurityEvent.setOperation(WSDL_DEFINITIONS);
try {
policyEnforcer.registerSecurityEvent(operationSecurityEvent);
+ fail("Exception expected");
} catch (WSSecurityException e) {
assertTrue(e.getCause() instanceof PolicyViolationException);
assertEquals(e.getCause().getMessage(),
@@ -493,6 +495,7 @@ public class TokenProtectionTest extends
AbstractPolicyTestBase {
try {
policyEnforcer.registerSecurityEvent(operationSecurityEvent);
+ fail("Exception expected");
} catch (WSSecurityException e) {
assertTrue(e.getCause() instanceof PolicyViolationException);
assertEquals(e.getCause().getMessage(),
@@ -625,6 +628,7 @@ public class TokenProtectionTest extends
AbstractPolicyTestBase {
try {
policyEnforcer.registerSecurityEvent(operationSecurityEvent);
+ fail("Exception expected");
} catch (WSSecurityException e) {
assertTrue(e.getCause() instanceof PolicyViolationException);
assertEquals(e.getCause().getMessage(),