🐛 修复登录自动建档把脱敏手机号写入司机档案
This commit is contained in:
@@ -59,7 +59,8 @@ class MpLoginSupportTest {
|
||||
@Test
|
||||
@DisplayName("新手机号微信登录:建号 + 建档,登录成功且无提示")
|
||||
void newPhoneCreatesAccountAndProfile() {
|
||||
MpUser created = mpUser(11L, PHONE, OPENID, "driver");
|
||||
// feign 下发时 phone 是脱敏值(MpUser.phone 标了 @Sensitive),建档必须仍用登录入参的真实号
|
||||
MpUser created = mpUser(11L, "138****0001", OPENID, "driver");
|
||||
when(mpUserClient.userByOpenid(TENANT_ID, OPENID)).thenReturn(R.data(null));
|
||||
when(mpUserClient.ensureUser(any(MpUserEnsureDTO.class))).thenReturn(R.data(created));
|
||||
when(mpUserClient.userInfoById(11L)).thenReturn(R.data(userInfo(created, "driver")));
|
||||
@@ -154,7 +155,7 @@ class MpLoginSupportTest {
|
||||
@Test
|
||||
@DisplayName("openid 命中且手机号不同但新号空闲:更新账号手机号")
|
||||
void openidHitWithFreePhoneUpdatesPhone() {
|
||||
MpUser openidAccount = mpUser(31L, "13900000000", OPENID, "driver");
|
||||
MpUser openidAccount = mpUser(31L, "139****0000", OPENID, "driver");
|
||||
when(mpUserClient.userByOpenid(TENANT_ID, OPENID)).thenReturn(R.data(openidAccount));
|
||||
when(mpUserClient.userByPhone(TENANT_ID, NEW_PHONE)).thenReturn(R.data(null));
|
||||
when(mpUserClient.updateUser(any(MpUser.class))).thenReturn(R.data(Boolean.TRUE));
|
||||
@@ -171,6 +172,22 @@ class MpLoginSupportTest {
|
||||
verify(mpUserClient, never()).ensureUser(any(MpUserEnsureDTO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("openid 命中且该手机号就是本账号:不重复更新手机号")
|
||||
void openidHitSameAccountDoesNotUpdatePhone() {
|
||||
MpUser openidAccount = mpUser(32L, "138****0001", OPENID, "driver");
|
||||
when(mpUserClient.userByOpenid(TENANT_ID, OPENID)).thenReturn(R.data(openidAccount));
|
||||
when(mpUserClient.userByPhone(TENANT_ID, PHONE)).thenReturn(R.data(openidAccount));
|
||||
when(mpUserClient.userInfoById(32L)).thenReturn(R.data(userInfo(openidAccount, "driver")));
|
||||
when(driverClient.ensureProfile(any(DriverEnsureProfileDTO.class))).thenReturn(R.data(profileResult()));
|
||||
|
||||
OAuth2User user = mpLoginSupport.ensureLoginAccount(TENANT_ID, PHONE, OPENID);
|
||||
|
||||
assertEquals("32", user.getUserId());
|
||||
verify(mpUserClient, never()).updateUser(any(MpUser.class));
|
||||
verify(mpUserClient, never()).ensureUser(any(MpUserEnsureDTO.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("纯 admin 身份:不建司机档案")
|
||||
void adminOnlyDoesNotCreateProfile() {
|
||||
|
||||
Reference in New Issue
Block a user