Skip to content

Commit 02da966

Browse files
authored
fix: maven构建失败 (#5872)
2 parents f85141f + c70a68a commit 02da966

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

laokou-common/laokou-common-mybatis-plus/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
<groupId>com.alibaba</groupId>
7171
<artifactId>druid-spring-boot-4-starter</artifactId>
7272
</exclusion>
73+
<exclusion>
74+
<groupId>org.mybatis</groupId>
75+
<artifactId>mybatis-spring</artifactId>
76+
</exclusion>
7377
</exclusions>
7478
</dependency>
7579
<dependency>

laokou-service/laokou-auth/laokou-auth-app/src/main/java/org/laokou/auth/service/validator/AuthorizationCodeAuthParamValidator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.laokou.auth.model.AuthA;
2121
import org.laokou.auth.model.validator.AuthParamValidator;
22+
import org.laokou.auth.model.valueobject.CaptchaV;
2223
import org.laokou.auth.model.valueobject.UserV;
2324
import org.laokou.common.i18n.util.ParamValidator;
2425
import org.springframework.stereotype.Component;
@@ -37,9 +38,14 @@ public class AuthorizationCodeAuthParamValidator implements AuthParamValidator {
3738
@Override
3839
public void validateAuth(AuthA authA) {
3940
UserV userV = authA.getUserV();
41+
CaptchaV captchaV = authA.getCaptchaV();
4042
ParamValidator.validate(authA.getValidateName(),
4143
// 校验租户编码
4244
OAuth2ParamValidator.validateTenantCode(userV.tenantCode()),
45+
// 校验UUID
46+
OAuth2ParamValidator.validateUuid(captchaV.uuid()),
47+
// 校验验证码
48+
OAuth2ParamValidator.validateCaptcha(captchaV.captcha()),
4349
// 校验用户名
4450
OAuth2ParamValidator.validateUsername(userV.username()),
4551
// 校验密码

laokou-service/laokou-auth/laokou-auth-domain/src/main/java/org/laokou/auth/model/AuthA.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public AuthA createMailAuth() throws Exception {
219219

220220
public AuthA createAuthorizationCodeAuth() throws Exception {
221221
this.grantType = GrantType.AUTHORIZATION_CODE;
222+
this.captchaV = getCaptchaVByAuthorizationCodeAuth();
222223
this.userV = getUserVByAuthorizationCodeAuth();
223224
return create();
224225
}
@@ -407,6 +408,10 @@ private String getParameterValue(String key) {
407408
return parameterMap.getOrDefault(key, new String[] { StringConstants.EMPTY })[0];
408409
}
409410

411+
private CaptchaV getCaptchaVByAuthorizationCodeAuth() {
412+
return getCaptchaVByUsernamePasswordAuth();
413+
}
414+
410415
private CaptchaV getCaptchaVByUsernamePasswordAuth() {
411416
String uuid = getParameterValue(Constants.UUID);
412417
String captcha = getParameterValue(Constants.CAPTCHA);

laokou-service/laokou-auth/laokou-auth-domain/src/test/java/org/laokou/auth/model/DomainServiceTest.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,16 @@ void test_auth_test_success() throws Exception {
295295
}
296296

297297
@Test
298-
@DisplayName("Test authorization code password auth success")
298+
@DisplayName("Test authorization code auth success")
299299
void test_auth_authorizationCode_success() throws Exception {
300300
createAuthorizationCodeAuthInfo(createAuthorizationCodeAuthParam());
301301
AuthA authorizationCodeAuth = createAuth().createAuthorizationCodeAuth();
302302
Assertions.assertThat(authorizationCodeAuth).isNotNull();
303303
Assertions.assertThatCode(() -> domainService.auth(authorizationCodeAuth)).doesNotThrowAnyException();
304304
Mockito.verify(tenantGateway, Mockito.times(1)).getTenantId(this.tenantCode);
305305
Mockito.verify(httpRequest, Mockito.times(1)).getParameterMap();
306+
Mockito.verify(captchaValidator, Mockito.times(1))
307+
.validateCaptcha(RedisKeyUtils.getAuthorizationCodeAuthCaptchaKey(this.uuid), this.captcha);
306308
Mockito.verify(passwordValidator, Mockito.times(1)).validatePassword(this.password, this.password);
307309
Mockito.verify(userGateway, Mockito.times(1)).getUserProfile(createUserVByAuthorizationCode());
308310
Mockito.verify(menuGateway, Mockito.times(1)).getMenuPermissions(createUserE());
@@ -432,9 +434,16 @@ private void createAuthorizationCodeAuthInfo(AuthorizationCodAuthParam authoriza
432434
Mockito.doAnswer(invocation -> {
433435
AuthA authA = invocation.getArgument(0);
434436
UserV userV = authA.getUserV();
437+
CaptchaV captchaV = authA.getCaptchaV();
435438
if (StringExtUtils.isEmpty(userV.tenantCode())) {
436439
throw new IllegalArgumentException("tenant code must not be empty");
437440
}
441+
if (StringExtUtils.isEmpty(captchaV.uuid())) {
442+
throw new IllegalArgumentException("uuid must not be empty");
443+
}
444+
if (StringExtUtils.isEmpty(captchaV.captcha())) {
445+
throw new IllegalArgumentException("captcha must not be empty");
446+
}
438447
if (StringExtUtils.isEmpty(userV.username())) {
439448
throw new IllegalArgumentException("username must not be empty");
440449
}
@@ -444,6 +453,7 @@ private void createAuthorizationCodeAuthInfo(AuthorizationCodAuthParam authoriza
444453
return null;
445454
}).when(authorizationCodeAuthParamValidator).validateAuth(Mockito.any());
446455
Mockito.when(passwordValidator.validatePassword(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
456+
Mockito.when(captchaValidator.validateCaptcha(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
447457
Mockito.when(tenantGateway.getTenantId(Mockito.anyString())).thenReturn(1L);
448458
Mockito.when(roleGateway.getDataScopes(Mockito.any())).thenReturn(Set.of("self", "custom"));
449459
Mockito.when(deptGateway.getDeptIds(Mockito.any(), Mockito.any())).thenReturn(Set.of(1L));
@@ -453,8 +463,11 @@ private void createAuthorizationCodeAuthInfo(AuthorizationCodAuthParam authoriza
453463
Map<String, String[]> params = MapUtils.newHashMap(4);
454464
params.put(Constants.USERNAME, new String[] { authorizationCodeAuthParam.username() });
455465
params.put(Constants.PASSWORD, new String[] { authorizationCodeAuthParam.password() });
466+
params.put(Constants.UUID, new String[] { authorizationCodeAuthParam.uuid() });
467+
params.put(Constants.CAPTCHA, new String[] { authorizationCodeAuthParam.captcha() });
456468
params.put(Constants.TENANT_CODE, new String[] { authorizationCodeAuthParam.tenantCode() });
457469
params.put(Constants.GRANT_TYPE, new String[] { authorizationCodeAuthParam.grantType() });
470+
458471
Mockito.when(httpRequest.getParameterMap()).thenReturn(params);
459472
}
460473

@@ -535,7 +548,7 @@ private TestAuthParam createTestAuthParam() {
535548
}
536549

537550
private AuthorizationCodAuthParam createAuthorizationCodeAuthParam() {
538-
return new AuthorizationCodAuthParam(this.username, this.password, this.tenantCode,
551+
return new AuthorizationCodAuthParam(this.uuid, this.captcha, this.username, this.password, this.tenantCode,
539552
GrantType.AUTHORIZATION_CODE.getCode());
540553
}
541554

@@ -552,7 +565,7 @@ private TestAuthParam createTestEmptyAuthParam() {
552565
}
553566

554567
private AuthorizationCodAuthParam createAuthorizationCodeEmptyAuthParam() {
555-
return new AuthorizationCodAuthParam(null, null, null, GrantType.AUTHORIZATION_CODE.getCode());
568+
return new AuthorizationCodAuthParam(null, null, null, null, null, GrantType.AUTHORIZATION_CODE.getCode());
556569
}
557570

558571
private UserV createUserVByUsernamePassword() throws Exception {
@@ -624,7 +637,8 @@ private record MailAuthParam(String mail, String code, String tenantCode, String
624637
private record TestAuthParam(String username, String password, String tenantCode, String grantType) {
625638
}
626639

627-
private record AuthorizationCodAuthParam(String username, String password, String tenantCode, String grantType) {
640+
private record AuthorizationCodAuthParam(String uuid, String captcha, String username, String password,
641+
String tenantCode, String grantType) {
628642
}
629643

630644
}

0 commit comments

Comments
 (0)