Skip to content

Commit

Permalink
feat: fix CI test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Oct 25, 2023
1 parent bf62a35 commit 444aad3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 48 deletions.
9 changes: 6 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<version>2.7.12</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -137,7 +137,7 @@
<dependency>
<groupId>org.casbin</groupId>
<artifactId>casdoor-java-sdk</artifactId>
<version>1.22.0</version>
<version>1.22.1</version>
</dependency>

<dependency>
Expand All @@ -155,7 +155,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.2</version>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -177,14 +177,17 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.8</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
</dependencies>

Expand Down
41 changes: 20 additions & 21 deletions src/main/java/org/casbin/casdoor/config/CasdoorAutoConfigure.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,62 @@ public class CasdoorAutoConfigure {

@Bean
@ConditionalOnMissingBean
CasdoorUserService getCasdoorUserService(CasdoorConfiguration config) {
return new CasdoorUserService(config);
UserService getUserService(CasdoorConfiguration config) {
return new UserService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorAuthService getCasdoorAuthService(CasdoorConfiguration config) {
return new CasdoorAuthService(config);
AuthService getAuthService(CasdoorConfiguration config) {
return new AuthService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorSmsService getCasdoorSmsService(CasdoorConfiguration config) {
return new CasdoorSmsService(config);
SmsService getCasdoorSmsService(CasdoorConfiguration config) {
return new SmsService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorEmailService getCasdoorEmailService(CasdoorConfiguration config) {
return new CasdoorEmailService(config);
EmailService getCasdoorEmailService(CasdoorConfiguration config) {
return new EmailService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorResourceService getCasdoorResourceService(CasdoorConfiguration config) {
return new CasdoorResourceService(config);
ResourceService getCasdoorResourceService(CasdoorConfiguration config) {
return new ResourceService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorAccountService getCasdoorAccountService(CasdoorConfiguration config) {
return new CasdoorAccountService(config);
AccountService getCasdoorAccountService(CasdoorConfiguration config) {
return new AccountService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorEnforcerService getCasdoorEnforcerService(CasdoorConfiguration config) {
return new CasdoorEnforcerService(config);
EnforcerService getCasdoorEnforcerService(CasdoorConfiguration config) {
return new EnforcerService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorPermissionService getCasdoorPermissionService(CasdoorConfiguration config) {
return new CasdoorPermissionService(config);
PermissionService getCasdoorPermissionService(CasdoorConfiguration config) {
return new PermissionService(config);
}


@Bean
@ConditionalOnMissingBean
CasdoorRoleService getCasdoorRoleService(CasdoorConfiguration config) {
return new CasdoorRoleService(config);
RoleService getCasdoorRoleService(CasdoorConfiguration config) {
return new RoleService(config);
}

@Bean
@ConditionalOnMissingBean
CasdoorTokenService getCasdoorTokenService(CasdoorConfiguration config) {
return new CasdoorTokenService(config);
TokenService getCasdoorTokenService(CasdoorConfiguration config) {
return new TokenService(config);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
@EqualsAndHashCode(callSuper = true)
@Data
@ConfigurationProperties(prefix = "casdoor")
public class CasdoorConfiguration extends CasdoorConfig{}
public class CasdoorConfiguration extends Config{}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.casbin.casdoor;

import org.casbin.casdoor.entity.CasdoorUser;
import org.casbin.casdoor.service.CasdoorAuthService;
import org.casbin.casdoor.service.CasdoorUserService;
import org.casbin.casdoor.entity.User;
import org.casbin.casdoor.service.AuthService;
import org.casbin.casdoor.service.UserService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -17,45 +17,45 @@
@TestPropertySource("classpath:test.properties")
public class CasdoorSpringBootStarterApplicationTest {
@Resource
CasdoorUserService casdoorUserService;
UserService userService;

@Resource
CasdoorAuthService casdoorAuthService;
AuthService authService;

@Test
public void testInjection() {
Assert.assertNotNull(casdoorAuthService);
Assert.assertNotNull(casdoorUserService);
Assert.assertNotNull(authService);
Assert.assertNotNull(userService);
}

@Test
public void testGetUser() throws Exception {
Assert.assertNotNull(casdoorUserService.getUser("admin"));
Assert.assertNotNull(userService.getUser("admin"));
}

@Test
public void testGetUsers() throws Exception {
Assert.assertNotNull(casdoorUserService.getUsers());
Assert.assertNotNull(userService.getUsers());
}

@Test
public void testAddUser() throws Exception {
CasdoorUser user = casdoorUserService.getUser("admin");
user.setName("testAdmin");
user.setId("qwertyuio");
Assert.assertEquals("Affected", casdoorUserService.addUser(user).getData());
User user = userService.getUser("admin");
user.name = "testAdmin";
user.id = "qwertyuio";
Assert.assertEquals("Affected", userService.addUser(user).getData());
}

@Test
public void testUpdateUser() throws Exception {
CasdoorUser user = casdoorUserService.getUser("testAdmin");
user.setDisplayName("testUpdateAdmin");
Assert.assertEquals("Affected", casdoorUserService.updateUser(user).getData());
User user = userService.getUser("testAdmin");
user.displayName = "testUpdateAdmin";
Assert.assertEquals("Affected", userService.updateUser(user).getData());
}

@Test
public void testDeleteUser() throws Exception {
CasdoorUser user = casdoorUserService.getUser("testAdmin");
Assert.assertEquals("Affected", casdoorUserService.deleteUser(user).getData());
User user = userService.getUser("testAdmin");
Assert.assertEquals("Affected", userService.deleteUser(user).getData());
}
}
10 changes: 5 additions & 5 deletions src/test/resources/test.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
casdoor.endpoint = http://localhost:8000
casdoor.clientId = 874e3e05e58d50148c65
casdoor.clientSecret = 41510b84c7267ad2e4d2b51096b7f11dc9c5fdc8
casdoor.endpoint = https://demo.casdoor.com
casdoor.clientId = 294b09fbc17f95daf2fe
casdoor.clientSecret = dd8982f7046ccba1bbd7851d5c1ece4e52bf039d
casdoor.jwtSecret = CasdoorSecret
casdoor.organizationName = built-in
casdoor.applicationName = app-built-in
casdoor.organizationName = casbin
casdoor.applicationName = app-vue-python-example

0 comments on commit 444aad3

Please sign in to comment.