sumanth-pasupuleti commented on a change in pull request #1028: URL: https://github.com/apache/cassandra/pull/1028#discussion_r645781195
########## File path: test/unit/org/apache/cassandra/audit/PasswordObfuscatorTest.java ########## @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.audit; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class PasswordObfuscatorTest +{ + @Test + public void testCreatRoleWithLoginPriorToPassword() + { + assertEquals(String.format("CREATE ROLE role1 WITH LOGIN = true AND PASSWORD = '%s'", PasswordObfuscator.OBFUSCATED_TOKEN), PasswordObfuscator.instance.obfuscate("CREATE ROLE role1 WITH LOGIN = true AND PASSWORD = '123'")); + } + + @Test + public void testCreatRoleWithLoginAfterPassword() + { + assertEquals(String.format("CREATE ROLE role1 WITH password = '%s' AND LOGIN = true", PasswordObfuscator.OBFUSCATED_TOKEN), PasswordObfuscator.instance.obfuscate("CREATE ROLE role1 WITH password = '123' AND LOGIN = true")); + } + + @Test + public void testCreateRoleWithoutPassword() + { + assertEquals("CREATE ROLE role1", PasswordObfuscator.instance.obfuscate("CREATE ROLE role1")); + } + + @Test + public void testAlterRoleWithPassword() + { + assertEquals(String.format("ALTER ROLE role1 with PASSWORD = '%s'", PasswordObfuscator.OBFUSCATED_TOKEN), PasswordObfuscator.instance.obfuscate("ALTER ROLE role1 with PASSWORD = '123'")); + } + + @Test + public void testAlterRoleWithoutPassord() + { + assertEquals("ALTER ROLE role1", PasswordObfuscator.instance.obfuscate("ALTER ROLE role1")); + } + + @Test + public void testCreateUserWithPassword() + { + assertEquals(String.format("CREATE USER user1 with PASSWORD = '%s'", PasswordObfuscator.OBFUSCATED_TOKEN), PasswordObfuscator.instance.obfuscate("CREATE USER user1 with PASSWORD = '123'")); + } + + @Test + public void testCreateUserWithoutPassword() + { + assertEquals("CREATE USER user1", PasswordObfuscator.instance.obfuscate("CREATE USER user1")); + } + + @Test + public void testAlterUserWithPassword() Review comment: I have added these variants into PasswordObfuscatorTest.java -- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

