|
|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.yau.digitalrmb.platformintegration.infrastructure;
|
|
|
|
package com.yau.digitalrmb.platformintegration.infrastructure;
|
|
|
|
|
|
|
|
|
|
|
|
import com.yau.digitalrmb.platformintegration.application.PlatformIdentityRepository;
|
|
|
|
import com.yau.digitalrmb.platformintegration.application.PlatformIdentityRepository;
|
|
|
|
|
|
|
|
import com.yau.digitalrmb.platformintegration.domain.PlatformCredential;
|
|
|
|
import com.yau.digitalrmb.platformintegration.domain.PlatformActor;
|
|
|
|
import com.yau.digitalrmb.platformintegration.domain.PlatformActor;
|
|
|
|
import com.yau.digitalrmb.platformintegration.domain.PlatformRole;
|
|
|
|
import com.yau.digitalrmb.platformintegration.domain.PlatformRole;
|
|
|
|
import org.h2.jdbcx.JdbcDataSource;
|
|
|
|
import org.h2.jdbcx.JdbcDataSource;
|
|
|
|
@ -16,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
|
|
|
|
class JdbcPlatformIdentityRepositoryTest {
|
|
|
|
class JdbcPlatformIdentityRepositoryTest {
|
|
|
|
private DataSource dataSource;
|
|
|
|
private DataSource dataSource;
|
|
|
|
private PlatformIdentityRepository repository;
|
|
|
|
private JdbcPlatformIdentityRepository repository;
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach
|
|
|
|
@BeforeEach
|
|
|
|
void setUp() throws Exception {
|
|
|
|
void setUp() throws Exception {
|
|
|
|
@ -52,8 +53,20 @@ class JdbcPlatformIdentityRepositoryTest {
|
|
|
|
assertThat(repository.findByPlatformUserId(202L)).isEmpty();
|
|
|
|
assertThat(repository.findByPlatformUserId(202L)).isEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void resolvesCredentialOnlyForEnabledSupportedPlatformUsers() throws Exception {
|
|
|
|
|
|
|
|
execute("INSERT INTO core_user(ID, CODE, NAME, PASSWORD, STATE, JOB_TYPE1, DEL_FLAG) VALUES (301, 'tzs001', '教师', '123qwe', 'S1', 'JT_S_02', 0)");
|
|
|
|
|
|
|
|
execute("INSERT INTO teacher(teacher_id, user_id, teacher_status, add_time) VALUES (3, 301, 1, '2026-01-01 00:00:00')");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlatformCredential credential = repository.findCredential(301L).orElseThrow();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(credential.actor().account()).isEqualTo("tzs001");
|
|
|
|
|
|
|
|
assertThat(credential.rawPassword()).isEqualTo("123qwe");
|
|
|
|
|
|
|
|
assertThat(repository.findCredential(999L)).isEmpty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void createSchema() throws Exception {
|
|
|
|
private void createSchema() throws Exception {
|
|
|
|
execute("CREATE TABLE core_user(ID BIGINT PRIMARY KEY, CODE VARCHAR(64), NAME VARCHAR(64), STATE VARCHAR(16), JOB_TYPE1 VARCHAR(16), DEL_FLAG INT)");
|
|
|
|
execute("CREATE TABLE core_user(ID BIGINT PRIMARY KEY, CODE VARCHAR(64), NAME VARCHAR(64), PASSWORD VARCHAR(128), STATE VARCHAR(16), JOB_TYPE1 VARCHAR(16), DEL_FLAG INT)");
|
|
|
|
execute("CREATE TABLE teacher(teacher_id BIGINT PRIMARY KEY, user_id BIGINT, teacher_status INT, add_time TIMESTAMP)");
|
|
|
|
execute("CREATE TABLE teacher(teacher_id BIGINT PRIMARY KEY, user_id BIGINT, teacher_status INT, add_time TIMESTAMP)");
|
|
|
|
execute("CREATE TABLE student(student_id BIGINT PRIMARY KEY, user_id BIGINT, student_status INT, add_time TIMESTAMP)");
|
|
|
|
execute("CREATE TABLE student(student_id BIGINT PRIMARY KEY, user_id BIGINT, student_status INT, add_time TIMESTAMP)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|