[ISSUE #7943] Add bazel config for auth module and fix bazel test (#7944)

This commit is contained in:
dingshuangxi888
2024-03-20 14:38:01 +08:00
committed by GitHub
parent c727f3a069
commit f2dd5b06fe
15 changed files with 107 additions and 58 deletions
+77
View File
@@ -0,0 +1,77 @@
#
# 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.
#
load("//bazel:GenTestRules.bzl", "GenTestRules")
java_library(
name = "auth",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//acl",
"//common",
"//remoting",
"//srvutil",
"@maven//:commons_codec_commons_codec",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:commons_collections_commons_collections",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:org_apache_rocketmq_rocketmq_proto",
"@maven//:org_slf4j_slf4j_api",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:io_grpc_grpc_api",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"@maven//:io_netty_netty_all",
"@maven//:com_google_guava_guava",
"@maven//:org_apache_rocketmq_rocketmq_rocksdb",
],
)
java_library(
name = "tests",
srcs = glob(["src/test/java/**/*.java"]),
resources = glob(["src/test/resources/**/*.yml"]),
visibility = ["//visibility:public"],
deps = [
":auth",
"//acl",
"//:test_deps",
"//common",
"//remoting",
"@maven//:commons_codec_commons_codec",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:commons_collections_commons_collections",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:org_apache_rocketmq_rocketmq_proto",
"@maven//:org_slf4j_slf4j_api",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:io_grpc_grpc_api",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"@maven//:io_netty_netty_all",
"@maven//:com_google_guava_guava",
"@maven//:org_apache_rocketmq_rocketmq_rocksdb",
],
)
GenTestRules(
name = "GeneratedTestRules",
test_files = glob(["src/test/java/**/*Test.java"]),
deps = [
":tests",
],
)
@@ -16,7 +16,7 @@
*/
package org.apache.rocketmq.auth.authentication.manager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSON;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.StringUtils;
@@ -35,7 +35,6 @@ import org.apache.rocketmq.auth.authentication.model.User;
import org.apache.rocketmq.auth.config.AuthConfig;
import org.apache.rocketmq.common.config.ConfigRocksDBStorage;
import org.apache.rocketmq.common.thread.ThreadPoolMonitor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.rocksdb.RocksIterator;
public class LocalAuthenticationMetadataProvider implements AuthenticationMetadataProvider {
@@ -152,7 +151,7 @@ public class LocalAuthenticationMetadataProvider implements AuthenticationMetada
}
@Override
public User load(@NonNull String username) {
public User load(String username) {
try {
byte[] keyBytes = username.getBytes(StandardCharsets.UTF_8);
byte[] valueBytes = storage.get(keyBytes);
@@ -40,7 +40,6 @@ import org.apache.rocketmq.auth.authorization.model.PolicyEntry;
import org.apache.rocketmq.auth.config.AuthConfig;
import org.apache.rocketmq.common.config.ConfigRocksDBStorage;
import org.apache.rocketmq.common.thread.ThreadPoolMonitor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.rocksdb.RocksIterator;
public class LocalAuthorizationMetadataProvider implements AuthorizationMetadataProvider {
@@ -181,7 +180,7 @@ public class LocalAuthorizationMetadataProvider implements AuthorizationMetadata
}
@Override
public Acl load(@NonNull String subjectKey) {
public Acl load(String subjectKey) {
try {
byte[] keyBytes = subjectKey.getBytes(StandardCharsets.UTF_8);
Subject subject = Subject.of(subjectKey);
@@ -45,8 +45,8 @@ import org.apache.rocketmq.common.constant.CommonConstants;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.resource.ResourcePattern;
import org.apache.rocketmq.common.resource.ResourceType;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AuthMigrator {
@@ -30,7 +30,6 @@ import org.apache.rocketmq.common.constant.GrpcConstants;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.remoting.protocol.RequestCode;
import org.apache.rocketmq.remoting.protocol.header.SendMessageRequestHeader;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -110,7 +109,7 @@ public class DefaultAuthenticationContextBuilderTest {
}
@Override
public int compareTo(@NotNull ChannelId o) {
public int compareTo(ChannelId o) {
return 0;
}
};
@@ -72,7 +72,6 @@ import org.apache.rocketmq.remoting.protocol.header.UpdateConsumerOffsetRequestH
import org.apache.rocketmq.remoting.protocol.heartbeat.ConsumerData;
import org.apache.rocketmq.remoting.protocol.heartbeat.HeartbeatData;
import org.apache.rocketmq.remoting.protocol.heartbeat.SubscriptionData;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -499,7 +498,7 @@ public class DefaultAuthorizationContextBuilderTest {
}
@Override
public int compareTo(@NotNull ChannelId o) {
public int compareTo(ChannelId o) {
return 0;
}
};
+4
View File
@@ -22,6 +22,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//acl",
"//auth",
"//client",
"//common",
"//filter",
@@ -30,6 +31,7 @@ java_library(
"//store",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_luben_zstd_jni",
"@maven//:com_google_guava_guava",
"@maven//:com_googlecode_concurrentlinkedhashmap_concurrentlinkedhashmap_lru",
@@ -73,12 +75,14 @@ java_library(
":broker",
"//:test_deps",
"//acl",
"//auth",
"//client",
"//common",
"//filter",
"//remoting",
"//store",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_google_guava_guava",
"@maven//:io_netty_netty_all",
"@maven//:org_apache_commons_commons_lang3",
@@ -264,11 +264,11 @@ public class MQAdminImpl {
public MessageExt viewMessage(String topic, String msgId)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
MessageId messageId = null;
MessageId messageId;
try {
messageId = MessageDecoder.decodeMessageId(msgId);
return this.mQClientFactory.getMQAdminImpl().viewMessage(topic, msgId);
} catch (Exception ignored) {
} catch (Exception e) {
throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
}
return this.mQClientFactory.getMQClientAPIImpl().viewMessage(NetworkUtil.socketAddress2String(messageId.getAddress()),
topic, messageId.getOffset(), timeoutMillis);
+6
View File
@@ -22,6 +22,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_luben_zstd_jni",
"@maven//:com_google_guava_guava",
"@maven//:commons_collections_commons_collections",
@@ -36,6 +37,8 @@ java_library(
"@maven//:io_opentelemetry_opentelemetry_sdk_common",
"@maven//:io_opentelemetry_opentelemetry_sdk_metrics",
"@maven//:io_opentelemetry_opentelemetry_exporter_logging_otlp",
"@maven//:io_grpc_grpc_api",
"@maven//:io_grpc_grpc_context",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:org_lz4_lz4_java",
"@maven//:io_github_aliyunmq_rocketmq_slf4j_api",
@@ -53,6 +56,7 @@ java_library(
"//:test_deps",
"@maven//:com_google_guava_guava",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:io_netty_netty_all",
"@maven//:io_opentelemetry_opentelemetry_api",
"@maven//:io_opentelemetry_opentelemetry_context",
@@ -61,6 +65,8 @@ java_library(
"@maven//:io_opentelemetry_opentelemetry_sdk",
"@maven//:io_opentelemetry_opentelemetry_sdk_common",
"@maven//:io_opentelemetry_opentelemetry_sdk_metrics",
"@maven//:io_grpc_grpc_api",
"@maven//:io_grpc_grpc_context",
"@maven//:org_apache_commons_commons_lang3",
],
resources = glob(["src/test/resources/certs/*.pem"]) + glob(["src/test/resources/certs/*.key"])
+5 -1
View File
@@ -22,6 +22,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//acl",
"//auth",
"//broker",
"//client",
"//common",
@@ -30,6 +31,7 @@ java_library(
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:com_github_luben_zstd_jni",
"@maven//:com_google_code_findbugs_jsr305",
@@ -78,7 +80,8 @@ java_library(
],
visibility = ["//visibility:public"],
deps = [
"//acl",
"//acl",
"//auth",
":proxy",
"//:test_deps",
"//broker",
@@ -87,6 +90,7 @@ java_library(
"//remoting",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:com_google_guava_guava",
"@maven//:com_google_protobuf_protobuf_java",
+2
View File
@@ -39,6 +39,7 @@ java_library(
"@maven//:io_github_aliyunmq_rocketmq_slf4j_api",
"@maven//:io_github_aliyunmq_rocketmq_logback_classic",
"@maven//:commons_collections_commons_collections",
"@maven//:org_reflections_reflections",
],
)
@@ -66,6 +67,7 @@ java_library(
"@maven//:org_apache_tomcat_annotations_api",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:org_jetbrains_annotations",
"@maven//:org_reflections_reflections",
],
resources = glob(["src/test/resources/certs/*.pem"]) + glob(["src/test/resources/certs/*.key"])
)
+3 -1
View File
@@ -42,6 +42,7 @@ java_library(
"@maven//:com_alibaba_fastjson",
"@maven//:org_apache_rocketmq_rocketmq_rocksdb",
"@maven//:commons_collections_commons_collections",
"@maven//:org_slf4j_slf4j_api",
],
)
@@ -68,8 +69,9 @@ java_library(
"@maven//:org_apache_commons_commons_lang3",
"@maven//:com_google_guava_guava",
"@maven//:io_github_aliyunmq_rocketmq_slf4j_api",
"@maven//:io_github_aliyunmq_rocketmq_shaded_slf4j_api_bridge",
"@maven//:io_github_aliyunmq_rocketmq_logback_classic",
"@maven//:net_java_dev_jna_jna",
"@maven//:org_slf4j_slf4j_api",
],
)
@@ -1,21 +0,0 @@
/*
* 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.rocketmq.tieredstore.file;
public class FlatConsumeQueueFileTest {
}
@@ -1,21 +0,0 @@
/*
* 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.rocketmq.tieredstore.provider;
public class PosixFileSegmentTest {
}