forked from apache/rocketmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apache#8615 fix DeleteUserSubCommand command failed when acl2.0 authe…
…ntication enabled and authorization disabled
- Loading branch information
1 parent
945e7ea
commit ad1fd18
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...rg/apache/rocketmq/auth/authorization/provider/AuthorizationDisabledMetadataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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.auth.authorization.provider; | ||
|
||
import org.apache.rocketmq.auth.authentication.model.Subject; | ||
import org.apache.rocketmq.auth.authorization.model.Acl; | ||
import org.apache.rocketmq.auth.config.AuthConfig; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Supplier; | ||
|
||
public class AuthorizationDisabledMetadataProvider implements AuthorizationMetadataProvider { | ||
@Override | ||
public void initialize(AuthConfig authConfig, Supplier<?> metadataService) { | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> createAcl(Acl acl) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> deleteAcl(Subject subject) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> updateAcl(Acl acl) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Acl> getAcl(Subject subject) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<List<Acl>> listAcl(String subjectFilter, String resourceFilter) { | ||
return CompletableFuture.completedFuture(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...pache/rocketmq/auth/authorization/provider/AuthorizationDisabledMetadataProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.auth.authorization.provider; | ||
|
||
import org.apache.rocketmq.auth.authentication.model.User; | ||
import org.apache.rocketmq.auth.authorization.model.Acl; | ||
import org.apache.rocketmq.auth.config.AuthConfig; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class AuthorizationDisabledMetadataProviderTest { | ||
|
||
private AuthorizationDisabledMetadataProvider authorizationDisabledMetadataProvider; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
this.authorizationDisabledMetadataProvider = new AuthorizationDisabledMetadataProvider(); | ||
this.authorizationDisabledMetadataProvider.initialize(new AuthConfig(), null); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
this.authorizationDisabledMetadataProvider.shutdown(); | ||
} | ||
|
||
@Test | ||
public void createAcl() { | ||
CompletableFuture<Void> future = this.authorizationDisabledMetadataProvider.createAcl(new Acl()); | ||
Assert.assertTrue(future.isDone()); | ||
} | ||
|
||
@Test | ||
public void deleteAcl() { | ||
CompletableFuture<Void> future = this.authorizationDisabledMetadataProvider.deleteAcl(User.of("username")); | ||
Assert.assertTrue(future.isDone()); | ||
} | ||
|
||
@Test | ||
public void updateAcl() { | ||
CompletableFuture<Void> future = this.authorizationDisabledMetadataProvider.updateAcl(new Acl()); | ||
Assert.assertTrue(future.isDone()); | ||
} | ||
|
||
@Test | ||
public void getAcl() { | ||
CompletableFuture<Acl> future = this.authorizationDisabledMetadataProvider.getAcl(User.of("username")); | ||
Assert.assertTrue(future.isDone()); | ||
Assert.assertNull(future.join()); | ||
} | ||
|
||
@Test | ||
public void listAcl() { | ||
CompletableFuture<List<Acl>> future = this.authorizationDisabledMetadataProvider.listAcl(null, null); | ||
Assert.assertTrue(future.isDone()); | ||
Assert.assertNull(future.join()); | ||
} | ||
} |