This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a26c21106f0 Add more test cases on PostgreSQLAuthenticationEngineTest 
(#37975)
a26c21106f0 is described below

commit a26c21106f01deb68ddc8d2979ff8207aa286640
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Feb 6 20:15:43 2026 +0800

    Add more test cases on PostgreSQLAuthenticationEngineTest (#37975)
---
 .../PostgreSQLAuthenticationEngineTest.java              | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
index e7b8ec274a6..db0017ff1f1 100644
--- 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
+++ 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
@@ -256,6 +256,22 @@ class PostgreSQLAuthenticationEngineTest {
         assertThrows(PrivilegeNotGrantedException.class, () -> 
authenticationEngine.authenticate(channelHandlerContext, passwordPayload));
     }
     
+    @Test
+    void assertLoginWithAuthorizedDatabase() {
+        PostgreSQLPacketPayload payload = createStartupPayload(USERNAME, 
DATABASE_NAME);
+        AuthorityRule authorityRule = createAuthorityRule(new 
UserConfiguration(USERNAME, PASSWORD, "", null, false), Collections.emptyMap(), 
null);
+        MetaDataContexts metaDataContexts = 
createMetaDataContexts(authorityRule, true, DATABASE_NAME);
+        ContextManager contextManager = mockContextManager(metaDataContexts);
+        
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
+        authenticationEngine.authenticate(channelHandlerContext, payload);
+        byte[] md5Salt = getMd5Salt(authenticationEngine);
+        PostgreSQLPacketPayload passwordPayload = 
createPasswordMessage(createMd5Digest(USERNAME, PASSWORD, md5Salt));
+        AuthenticationResult actual = 
authenticationEngine.authenticate(channelHandlerContext, passwordPayload);
+        
verify(channelHandlerContext).write(any(PostgreSQLAuthenticationOKPacket.class));
+        
verify(channelHandlerContext).writeAndFlush(PostgreSQLReadyForQueryPacket.NOT_IN_TRANSACTION);
+        assertThat(actual.isFinished(), is(true));
+    }
+    
     @Test
     void assertLoginWithNullDatabase() {
         PostgreSQLPacketPayload payload = createStartupPayload(USERNAME, null);

Reply via email to