simonbence commented on code in PR #9115: URL: https://github.com/apache/nifi/pull/9115#discussion_r1727393737
########## nifi-commons/nifi-security-identity/src/test/java/org/apache/nifi/authorization/util/IdentityMappingUtilTest.java: ########## @@ -0,0 +1,156 @@ +/* + * 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.nifi.authorization.util; + +import org.apache.nifi.util.NiFiProperties; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +class IdentityMappingUtilTest { + + @Test + public void testIdentityMappingGeneration() { + final Map<String, String> properties = new HashMap<>(); + properties.putAll(getDnProperties()); + properties.putAll(getLdapProperties("UPPER")); + final NiFiProperties niFiProperties = new NiFiProperties(properties); + final List<IdentityMapping> identityMappings = IdentityMappingUtil.getIdentityMappings(niFiProperties); + + final Optional<IdentityMapping> dnMapping = identityMappings.stream().filter(im -> im.getKey().equals("dn")).findFirst(); + final Optional<IdentityMapping> ldapMapping = identityMappings.stream().filter(im -> im.getKey().equals("ldap")).findFirst(); + + Assertions.assertTrue(dnMapping.isPresent()); + Assertions.assertEquals("NONE", dnMapping.get().getTransform().name()); + + Assertions.assertTrue(ldapMapping.isPresent()); + Assertions.assertEquals("UPPER", ldapMapping.get().getTransform().name()); + } + + // NIFI-13409 TC1 Review Comment: The ticket number itself is kind of a duplication of the commit message. The primary peace of information is the "TC1" (2...5) which supposed to connect the given test method with a given test case from the ticket, as there is a 1to1 mapping between them. This is not a mandatory information but I found it useful for later usage. Adding only "TC1" to the comment would not suggest any relation to anything outside the test class, so I decided to keep it a bit verbosive. Please share your view on this, thanks! -- 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]
