-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: Update build and test dependencies #9645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
12bb819
bdb7120
e35c45f
d5e611c
93157a9
e25cdb0
773f64e
d187756
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| package org.apache.kafka.clients.admin; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * Representation of a SASL/SCRAM Mechanism. | ||
| * | ||
|
|
@@ -27,13 +29,15 @@ public enum ScramMechanism { | |
| SCRAM_SHA_256((byte) 1), | ||
| SCRAM_SHA_512((byte) 2); | ||
|
|
||
| private static final ScramMechanism[] VALUES = values(); | ||
|
|
||
| /** | ||
| * | ||
| * @param type the type indicator | ||
| * @return the instance corresponding to the given type indicator, otherwise {@link #UNKNOWN} | ||
| */ | ||
| public static ScramMechanism fromType(byte type) { | ||
| for (ScramMechanism scramMechanism : ScramMechanism.values()) { | ||
| for (ScramMechanism scramMechanism : VALUES) { | ||
| if (scramMechanism.type == type) { | ||
| return scramMechanism; | ||
| } | ||
|
|
@@ -49,8 +53,11 @@ public static ScramMechanism fromType(byte type) { | |
| * Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms, Section 4</a> | ||
| */ | ||
| public static ScramMechanism fromMechanismName(String mechanismName) { | ||
| ScramMechanism retvalFoundMechanism = ScramMechanism.valueOf(mechanismName.replace('-', '_')); | ||
| return retvalFoundMechanism != null ? retvalFoundMechanism : UNKNOWN; | ||
| String normalizedMechanism = mechanismName.replace('-', '_'); | ||
| return Arrays.stream(VALUES) | ||
| .filter(mechanism -> mechanism.name().equals(normalizedMechanism)) | ||
| .findFirst() | ||
| .orElse(UNKNOWN); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rondagostino looks like the original implementation didn't achieve the goal. I added a test that failed without this change.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, you are right: Thanks for catching/testing for/fixing it.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rondagostino do we need to cherry-pick this change to the 2.7 branch? I am not sure under which context this method is used and whether it's important enough to backport. |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * 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.kafka.clients.admin; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class ScramMechanismTest { | ||
|
|
||
| @Test | ||
| public void testFromMechanismName() { | ||
| assertEquals(ScramMechanism.UNKNOWN, ScramMechanism.fromMechanismName("UNKNOWN")); | ||
| assertEquals(ScramMechanism.SCRAM_SHA_256, ScramMechanism.fromMechanismName("SCRAM-SHA-256")); | ||
| assertEquals(ScramMechanism.SCRAM_SHA_512, ScramMechanism.fromMechanismName("SCRAM-SHA-512")); | ||
| assertEquals(ScramMechanism.UNKNOWN, ScramMechanism.fromMechanismName("some string")); | ||
| assertEquals(ScramMechanism.UNKNOWN, ScramMechanism.fromMechanismName("scram-sha-256")); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we reuse
mechanismName(https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/admin/ScramMechanism.java#L79) so we don't need this duplicate replacement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, applied it.