Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 1e65468

Browse files
authored
FF-73 added default users
* fixed tests. * Updated to 0.0.2, added unknown role, added UserBusinessService, added user count to SystemHealth * removed integrations test due to upcoming feature tests. * Update feature_branch_tests.yml
1 parent c747dd9 commit 1e65468

24 files changed

+174
-137
lines changed

.github/workflows/feature_branch_tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Feature Branch Release
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- 'feature/**'
@@ -44,5 +45,7 @@ jobs:
4445
run: |
4546
IMAGE_ID=$(docker images rest -q)
4647
VERSION=${{ steps.vars.outputs.branch }}
48+
IFS=';' read -ra ADDR <<< "$VERSION"
49+
VERSION=ADDR[1]
4750
docker tag $IMAGE_ID filefighter/rest:$VERSION
48-
docker push filefighter/rest:$VERSION
51+
docker push filefighter/rest:$VERSION

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>de.filefighter</groupId>
1212
<artifactId>rest</artifactId>
13-
<version>0.0.2-SNAPSHOT</version>
13+
<version>0.0.2</version>
1414
<name>rest</name>
1515
<description>RestApi</description>
1616

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package de.filefighter.rest.configuration;
2+
3+
import de.filefighter.rest.domain.user.data.persistance.UserEntitiy;
4+
import de.filefighter.rest.domain.user.data.persistance.UserRepository;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.boot.CommandLineRunner;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
import org.springframework.context.annotation.Profile;
11+
12+
@Configuration
13+
@Profile("dev")
14+
public class PrepareDataBaseProd {
15+
16+
private static final Logger LOG = LoggerFactory.getLogger(PrepareDataBaseProd.class);
17+
18+
@Bean
19+
CommandLineRunner initUserDataBase(UserRepository repository) {
20+
21+
//Note: when the admin user changes his/her password, a new refreshToken will be created.
22+
return args -> {
23+
LOG.info("Starting with clean user collection.");
24+
repository.deleteAll();
25+
LOG.info("Preloading default admin user: " + repository.save(new UserEntitiy(0L, "admin", "admin", "refreshToken1234", 0, 1)));
26+
LOG.info("Loading Users" + (repository.findAll().size() == 1 ? " was successful." : " failed."));
27+
};
28+
}
29+
}

src/main/java/de/filefighter/rest/config/RestConfiguration.java renamed to src/main/java/de/filefighter/rest/configuration/RestConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.filefighter.rest.config;
1+
package de.filefighter.rest.configuration;
22

33
import org.jetbrains.annotations.NotNull;
44
import org.springframework.context.annotation.Bean;

src/main/java/de/filefighter/rest/config/SwaggerConfiguration.java renamed to src/main/java/de/filefighter/rest/configuration/SwaggerConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.filefighter.rest.config;
1+
package de.filefighter.rest.configuration;
22

33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;

src/main/java/de/filefighter/rest/domain/filesystem/rest/FileSystemRestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.springframework.hateoas.EntityModel;
1111
import org.springframework.web.bind.annotation.*;
1212

13-
import static de.filefighter.rest.config.RestConfiguration.*;
13+
import static de.filefighter.rest.configuration.RestConfiguration.*;
1414

1515
@RestController
1616
@Api(value = "FileSystem Rest Controller", tags = {"FileSystem"})

src/main/java/de/filefighter/rest/domain/health/business/SystemHealthBusinessService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
package de.filefighter.rest.domain.health.business;
22

33
import de.filefighter.rest.domain.health.data.SystemHealth;
4+
import de.filefighter.rest.domain.user.business.UserBusinessService;
45
import org.springframework.stereotype.Service;
56

67
import java.time.Instant;
78

89
@Service
910
public class SystemHealthBusinessService {
1011

12+
private final UserBusinessService userBusinessService;
1113
private final long serverStartedAt;
1214

13-
public SystemHealthBusinessService() {
15+
public SystemHealthBusinessService(UserBusinessService userBusinessService) {
16+
this.userBusinessService = userBusinessService;
1417
this.serverStartedAt = this.getCurrentEpochSeconds();
1518
}
1619

1720
public SystemHealth getCurrentSystemHealthInfo(){
1821
long currentEpoch = getCurrentEpochSeconds();
1922
return SystemHealth.builder()
2023
.uptimeInSeconds(currentEpoch - serverStartedAt)
24+
.userCount(userBusinessService.getUserCount())
2125
.create();
2226
}
2327

src/main/java/de/filefighter/rest/domain/health/data/SystemHealth.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
@Builder(buildMethodName = "create")
1212
public class SystemHealth {
1313
private final long uptimeInSeconds;
14+
private final long userCount;
1415
}

src/main/java/de/filefighter/rest/domain/permission/rest/PermissionRestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.springframework.hateoas.EntityModel;
88
import org.springframework.web.bind.annotation.*;
99

10-
import static de.filefighter.rest.config.RestConfiguration.*;
10+
import static de.filefighter.rest.configuration.RestConfiguration.*;
1111

1212
@RestController
1313
@Api(value = "Permissions Controller", tags = {"Permissions"})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.filefighter.rest.domain.user.business;
2+
3+
import de.filefighter.rest.domain.user.data.persistance.UserRepository;
4+
import org.springframework.stereotype.Service;
5+
6+
@Service
7+
public class UserBusinessService {
8+
private final UserRepository userRepository;
9+
10+
public UserBusinessService(UserRepository userRepository) {
11+
this.userRepository = userRepository;
12+
}
13+
14+
public long getUserCount(){
15+
return userRepository.count();
16+
}
17+
}

0 commit comments

Comments
 (0)