efegokdemir commented on code in PR #4358:
URL: https://github.com/apache/logging-log4j2/pull/4358#discussion_r4149809286


##########
src/changelog/.2.x.x/4347_auth_encoding.xml:
##########
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns="https://logging.apache.org/xml/ns";
+       xsi:schemaLocation="https://logging.apache.org/xml/ns 
https://logging.apache.org/xml/ns/log4j-changelog-0.xsd";
+       type="fixed">
+  <issue id="4347" 
link="https://github.com/apache/logging-log4j2/issues/4347"/>

Review Comment:
   Correction: current HEAD e76c3a6 documents the UTF-8 default and links PR 
4358 in the changelog.



##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/BasicAuthorizationProviderTest.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.logging.log4j.core.util;
+
+import static java.nio.charset.StandardCharsets.ISO_8859_1;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.net.URLConnection;
+import java.util.Base64;
+import java.util.Properties;
+import org.apache.logging.log4j.util.PropertiesUtil;
+import org.junit.jupiter.api.Test;
+
+class BasicAuthorizationProviderTest {
+
+    @Test
+    void usesLegacyEncodingPropertyWhenPrimaryPropertyIsAbsent() throws 
Exception {
+        final Properties properties = new Properties();
+        properties.setProperty("logging.auth.username", "usér");
+        properties.setProperty("logging.auth.password", "passé");
+        properties.setProperty("logging.auth.encoding", ISO_8859_1.name());
+        final BasicAuthorizationProvider provider = new 
BasicAuthorizationProvider(new PropertiesUtil(properties));
+
+        final RecordingURLConnection connection = new RecordingURLConnection();
+        provider.addAuthorization(connection);
+
+        final String credentials = "usér:passé";
+        final String expected = "Basic " + 
Base64.getEncoder().encodeToString(credentials.getBytes(ISO_8859_1));
+        assertThat(connection.requestValue).isEqualTo(expected);
+    }

Review Comment:
   Correction: current HEAD e76c3a6 adds the no-encoding regression with 
non-ASCII credentials and asserts exact UTF-8 Basic Auth bytes.



-- 
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