Skip to content

Commit

Permalink
test: 修复DESPasswordServiceTest的测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
damingerdai committed Nov 8, 2024
1 parent 7bb3d3c commit d61a171
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,55 @@
package org.daming.hoteler.security.service.impl;

import org.daming.hoteler.config.prop.SecretProp;
import org.daming.hoteler.config.service.ISecretPropService;
import org.daming.hoteler.config.service.impl.SecretPropServiceImpl;
import org.daming.hoteler.service.IErrorService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
@ContextConfiguration(classes = DESPasswordServiceTest.TestConfig.class)
class DESPasswordServiceTest {

@Configuration
@ConfigurationProperties(prefix = "secret")
static class TestConfig {

@MockBean
public IErrorService errorService;

@Bean
public SecretProp secretProp() {
var prop = new SecretProp();
prop.setSalt("dc513dcf1de6941978deb973fe98c1f6");
prop.setPersonSalt("dc513dcf1de6941978deb973fe98c1f4");
prop.setKey("damingerdai");

return prop;
}

@Bean
public ISecretPropService secretPropService(SecretProp secretProp) {
return new SecretPropServiceImpl(secretProp);
}

@Bean
public DESPasswordService md5PasswordService(IErrorService errorService, ISecretPropService secretPropService) {

return new DESPasswordService(errorService, secretPropService);
}
}

@Autowired
private DESPasswordService desPasswordService;

Expand Down

0 comments on commit d61a171

Please sign in to comment.