gemmellr commented on a change in pull request #3851:
URL: https://github.com/apache/activemq-artemis/pull/3851#discussion_r751191562



##########
File path: 
artemis-commons/src/test/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodecTest.java
##########
@@ -39,20 +40,33 @@ public void testDefaultAlgorithm() throws Exception {
 
    @Test
    public void testOnewayAlgorithm() throws Exception {
-      DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
-      Map<String, String> params = new HashMap<>();
-      params.put(DefaultSensitiveStringCodec.ALGORITHM, 
DefaultSensitiveStringCodec.ONE_WAY);
-      codec.init(params);
+      testAlgorithm(DefaultSensitiveStringCodec.ONE_WAY);
+   }
+
+   @Test
+   public void testTwowayAlgorithm() throws Exception {
+      testAlgorithm(DefaultSensitiveStringCodec.TWO_WAY);
+   }
+
+   private void testAlgorithm(String algorithm) throws Exception {
+      DefaultSensitiveStringCodec codec = 
getDefaultSensitiveStringCodec(algorithm);
 
       String plainText = "some_password";
       String maskedText = codec.encode(plainText);
       log.debug("encoded value: " + maskedText);
 
-      //one way can't decode
-      try {
-         codec.decode(maskedText);
-         fail("one way algorithm can't decode");
-      } catch (IllegalArgumentException expected) {
+      if (algorithm.equals(DefaultSensitiveStringCodec.ONE_WAY)) {
+         //one way can't decode
+         try {
+            codec.decode(maskedText);
+            fail("one way algorithm can't decode");
+         } catch (IllegalArgumentException expected) {

Review comment:
       UnsupportedOperation or IllegalState would seem a far better fit, but if 
this is existing behaviour I guess perhaps retaining it might be the way to go.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to