Conversation
Alima777
left a comment
There was a problem hiding this comment.
Try to modify all test named test() or add javadoc for it. The naming method is sooo ambiguous and not intuitive to maintain.
|
|
||
| @Test | ||
| public void test() throws AuthException, IllegalPathException { |
There was a problem hiding this comment.
Add javadoc to explain what the test is about, and try not to name a test as just test()
| PathPrivilege pathPrivilege = new PathPrivilege(); | ||
| Set<Integer> set = new HashSet<>(); | ||
| set.add(1); | ||
| pathPrivilege.setPrivileges(set); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| Assert.assertFalse(AuthorityChecker.check(user.getName(), Collections.singletonList(new PartialPath(nodeName)), | ||
| OperatorType.CREATE_TIMESERIES, user.getName())); | ||
|
|
||
| Assert.assertFalse(AuthorityChecker.check(user.getName(), Collections.singletonList(new PartialPath(nodeName)), | ||
| OperatorType.DELETE_TIMESERIES, user.getName())); | ||
| } | ||
| } |
There was a problem hiding this comment.
It's not a good test. The user created has no privilege at all, so all assertions return false. The correct test method may be: 1. test the authority before granting, return false. 2. grant the privilege 3. test the authority again, return true.
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| public class LocalFileAuthorizerTest { |
There was a problem hiding this comment.
| public class LocalFileAuthorizerTest { | |
| public class BasicAuthorizerTest { |
There was a problem hiding this comment.
I think BasicAuthorizerTest is better..
There was a problem hiding this comment.
In fact, BasicAuthorizer getInstance return a LocalFileAuthorizer instance
server/src/test/java/org/apache/iotdb/db/auth/entity/UserTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/iotdb/db/auth/entity/RoleTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/iotdb/db/auth/entity/PathPrivilegeTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/iotdb/db/auth/authorizer/OpenIdAuthorizerTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/iotdb/db/auth/authorizer/OpenIdAuthorizerTest.java
Outdated
Show resolved
Hide resolved
…dAuthorizerTest.java Co-authored-by: Xiangwei Wei <34242296+Alima777@users.noreply.github.com>
…java Co-authored-by: Xiangwei Wei <34242296+Alima777@users.noreply.github.com>
…dAuthorizerTest.java Co-authored-by: Xiangwei Wei <34242296+Alima777@users.noreply.github.com>
…java Co-authored-by: Xiangwei Wei <34242296+Alima777@users.noreply.github.com>
…legeTest.java Co-authored-by: Xiangwei Wei <34242296+Alima777@users.noreply.github.com>
|
Hi, check the CI please. |
|
Kudos, SonarCloud Quality Gate passed!
|
add auth test UT