Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c7926ad
WIP FF-218 Write Code for ShowContents
open-schnick Dec 6, 2020
2a58b83
Added UserBusinessService.userWithUsernameDoesExist
open-schnick Dec 9, 2020
5564b1b
Renamed dto to DTO, removed PermissionSets from FileSystemItems.
open-schnick Dec 11, 2020
88065c3
FF-218 Added main functions.
open-schnick Dec 11, 2020
19e61fb
Added defaults to builder classes.
open-schnick Dec 11, 2020
fffaf1b
FF-218 Added FileSystemBusinessService.userIsAllowedToSeeFileSystemEn…
open-schnick Dec 11, 2020
62e4dd2
commented out tests.
open-schnick Dec 11, 2020
76e651f
Works but i need to rework the dto structure
open-schnick Dec 13, 2020
b42a454
FF-218 Should work now. Needs testing.
open-schnick Dec 13, 2020
4e9d898
Merge branch 'master' into feature/FF-218
open-schnick Dec 13, 2020
00f8e81
Fixed Merge Import Problems
open-schnick Dec 13, 2020
4442500
Fixed Merge Annotation Problem
open-schnick Dec 13, 2020
714efa7
Added missing @Data
open-schnick Dec 14, 2020
bcc695b
Added missing @Builder
open-schnick Dec 14, 2020
61a06c8
Added missing DummyFile.
open-schnick Dec 14, 2020
96cc381
Added Cors for local dev purposes only.
open-schnick Dec 16, 2020
882aa75
Cleanup
open-schnick Dec 16, 2020
cfb718d
Added more @Builder.default
open-schnick Dec 17, 2020
7812180
Fixed Test, Wrote UnitTests (1/2)
open-schnick Dec 17, 2020
64ab9f2
Fixed Test, Wrote UnitTests (2/2)
open-schnick Dec 17, 2020
b93945c
Added createBasicFilesForNewUser
open-schnick Dec 17, 2020
8580bec
Updated Sonar Hostname
open-schnick Dec 19, 2020
5ead455
Implemented Changes requested by @qvalentin
open-schnick Dec 19, 2020
77bd8a9
Ignored Stupid CodeSmells
open-schnick Dec 19, 2020
27202eb
Added TotalFileSize To SystemHealth
open-schnick Dec 19, 2020
13dcca0
Sonar needs to access over https
open-schnick Dec 19, 2020
ef5b06b
added import of ssl cert for reaching sonar
qvalentin Dec 19, 2020
1564a07
also trigger workflow when workflow config is changed
qvalentin Dec 19, 2020
9b78a8c
bad echo?
qvalentin Dec 19, 2020
2539776
changed passowrd
qvalentin Dec 19, 2020
733cba2
changed passowrd
qvalentin Dec 19, 2020
a3912c3
use default password
qvalentin Dec 19, 2020
99482f3
why did i take the password 'changeit' literally
qvalentin Dec 19, 2020
2d6bd99
debug
qvalentin Dec 19, 2020
5640741
remove debug
qvalentin Dec 19, 2020
62b0b46
added SONAR_SCANNER_OPTS
qvalentin Dec 19, 2020
0247bcc
ups wrong repo
qvalentin Dec 19, 2020
259e6c2
trying https
qvalentin Dec 19, 2020
f28cb5c
everything https
qvalentin Dec 19, 2020
2276a02
made it use http for the links
qvalentin Dec 19, 2020
ef76b52
added test image
qvalentin Dec 19, 2020
5f0421a
undo changes
qvalentin Dec 19, 2020
8a2edbf
Refactored Steps and Feature File.
open-schnick Dec 19, 2020
1b2ce05
Merge branch 'feature/FF-218' of https://github.com/filefighter/resta…
open-schnick Dec 19, 2020
3645bbf
no https for badges images
qvalentin Dec 20, 2020
cf2981f
Added same scenario but with groups
open-schnick Dec 20, 2020
5667bb3
Added Steps, Fixed the feature.
open-schnick Dec 20, 2020
f0e9733
Small fixes.
open-schnick Dec 20, 2020
47e3dee
Fixed Tests
open-schnick Dec 20, 2020
9f35a6d
Bumped Up Version to -> 0.0.6
open-schnick Dec 20, 2020
c2983c0
added .run to gitingore
qvalentin Dec 21, 2020
a8c7dbe
Revert Changes, set default profile to "test" while running tests, ad…
open-schnick Dec 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- 'src/**'
- 'pom.xml'
- '.github/workflows/tests.yml'

jobs:
Run_all_tests:
Expand All @@ -25,8 +26,13 @@ jobs:
docker create -p 27017:27017 --name FileFighterDB mongo:latest
docker start FileFighterDB
-
name: Run Tests and update Sonar
run: mvn clean verify sonar:sonar -s ./settings.xml
name: Run Tests and update Sonar (import cert first)
run: |
echo "${{ secrets.SSL_CERT }}" > filefighter.de_ssl_certificate.cer
yes yes | keytool -import -alias filefighterde -file filefighter.de_ssl_certificate.cer -storetype JKS -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit
mvn clean verify sonar:sonar -s ./settings.xml
rm filefighter.de_ssl_certificate.cer
keytool -delete -alias filefighterde -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit
env:
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
SONAR_PASSWORD: ${{ secrets.SONAR_PASSWORD }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ build/
!**/src/test/**/build/

### VS Code ###
.vscode/
.vscode/
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# RestApi
Backend REST API for FileFighter </br>
Backend REST API for FileFighter
![Docker Release](https://img.shields.io/github/v/release/filefighter/restapi?color=dark-green&label=Stable%20Version&logo=docker&style=for-the-badge)
![Docker Pulls](https://img.shields.io/docker/pulls/filefighter/rest?logo=docker&style=for-the-badge)</br>
[![Quality Gate Status](http://filefighter.ddns.net:9000/api/project_badges/measure?project=de.filefighter%3Arest&metric=alert_status)](http://filefighter.ddns.net:9000/dashboard?id=de.filefighter%3Arest)
[![Coverage](http://filefighter.ddns.net:9000/api/project_badges/measure?project=de.filefighter%3Arest&metric=coverage)](http://filefighter.ddns.net:9000/dashboard?id=de.filefighter%3Arest)
[![Lines of Code](http://filefighter.ddns.net:9000/api/project_badges/measure?project=de.filefighter%3Arest&metric=ncloc)](http://filefighter.ddns.net:9000/dashboard?id=de.filefighter%3Arest)
[![Security Rating](http://filefighter.ddns.net:9000/api/project_badges/measure?project=de.filefighter%3Arest&metric=security_rating)](http://filefighter.ddns.net:9000/dashboard?id=de.filefighter%3Arest)</br>
![Docker Pulls](https://img.shields.io/docker/pulls/filefighter/rest?logo=docker&style=for-the-badge)
[![Quality Gate Status](http://sonar.filefighter.de/api/project_badges/measure?project=de.filefighter%3Arest&metric=alert_status)](https://sonar.filefighter.de/dashboard?id=de.filefighter%3Arest)
[![Coverage](http://sonar.filefighter.de/api/project_badges/measure?project=de.filefighter%3Arest&metric=coverage)](https://sonar.filefighter.de/dashboard?id=de.filefighter%3Arest)
[![Lines of Code](http://sonar.filefighter.de/api/project_badges/measure?project=de.filefighter%3Arest&metric=ncloc)](https://sonar.filefighter.de/dashboard?id=de.filefighter%3Arest)
[![Security Rating](http://sonar.filefighter.de/api/project_badges/measure?project=de.filefighter%3Arest&metric=security_rating)](https://sonar.filefighter.de/dashboard?id=de.filefighter%3Arest)
![Latest Release](https://github.com/FileFighter/RestApi/workflows/Latest%20Release/badge.svg)
![Stable Release](https://github.com/FileFighter/RestApi/workflows/Stable%20Release/badge.svg)
![Tests](https://github.com/FileFighter/RestApi/workflows/Tests/badge.svg)
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>de.filefighter</groupId>
<artifactId>rest</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<name>RestApi</name>
<description>RestApi for FileFighter</description>

Expand Down Expand Up @@ -180,10 +180,8 @@
</includes>
<excludes>
<!-- NOT IMPLEMENTED YET -->
<!-- TODO: remove fs -->
<exclude>*FileSystemRestService</exclude>
<exclude>*PermissionRestService</exclude>
<exclude>*FileSystemBusinessService</exclude>
</excludes>
<limits>
<limit>
Expand Down
2 changes: 1 addition & 1 deletion settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</activation>
<properties>
<sonar.host.url>
http://filefighter.ddns.net:9000
https://sonar.filefighter.de
</sonar.host.url>
<sonar.login>${env.SONAR_LOGIN}</sonar.login>
<sonar.password>${env.SONAR_PASSWORD}</sonar.password>
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/de/filefighter/rest/configuration/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.filefighter.rest.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import java.util.ArrayList;

@Configuration
public class CorsConfig {

@Bean
@Profile({"dev","stage"})
public CorsFilter corsFilter() {
final CorsConfiguration config = new CorsConfiguration().applyPermitDefaultValues();
ArrayList<String> allowedOrigins = new ArrayList<>();
allowedOrigins.add("*");
config.setAllowedOrigins(allowedOrigins);

ArrayList<String> allowedMethods = new ArrayList<>();
allowedMethods.add("HEAD");
allowedMethods.add("GET");
allowedMethods.add("POST");
allowedMethods.add("PUT");
allowedMethods.add("DELETE");
allowedMethods.add("OPTIONS");
config.setAllowedMethods(allowedMethods);

final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
@Configuration
public class PrepareDataBase {

private static final String MESSAGE_ON_SUCCESS = " was successful.";
private static final String MESSAGE_ON_FAILURE = " failed.";
private static final String MESSAGE_ON_SUCCESS = "was successful.";
private static final String MESSAGE_ON_FAILURE = "failed.";

@Value("${server.port}")
int serverPort;
Expand All @@ -32,25 +32,26 @@ public class PrepareDataBase {

@Value("${filefighter.date}")
String date;


@SuppressWarnings("squid:S106")
@Bean
@Profile({"dev", "prod"})
CommandLineRunner veryImportantFileFighterStartScript() {
return args -> {
System.out.println();
System.out.println("-------------------------------< REST API >-------------------------------");
System.out.println();
System.out.println(" _____ _ _ _____ _ _ _ ");
System.out.println(" | ___| (_) | | ___ | ___| (_) __ _ | |__ | |_ ___ _ __ ");
System.out.println(" _____ _ _ _____ _ _ _");
System.out.println(" | ___| (_) | | ___ | ___| (_) __ _ | |__ | |_ ___ _ __");
System.out.println(" | |_ | | | | / _ \\ | |_ | | / _ | | '_ \\ | __| / _ \\ | '__|");
System.out.println(" | _| | | | | | __/ | _| | | | (_| | | | | | | |_ | __/ | | ");
System.out.println(" |_| |_| |_| \\___| |_| |_| \\__, | |_| |_| \\__| \\___| |_| ");
System.out.println(" |___/ ");
System.out.println(" Version v" + version + " Last updated at " + date + " ");
System.out.println(" Developed by Gimleux, Valentin, Open-Schnick. ");
System.out.println(" Development Blog: https://filefighter.github.io ");
System.out.println(" The code can be found at: https://www.github.com/filefighter ");
System.out.println(" Running on http://localhost:" + serverPort);
System.out.println(" | _| | | | | | __/ | _| | | | (_| | | | | | | |_ | __/ | |");
System.out.println(" |_| |_| |_| \\___| |_| |_| \\__, | |_| |_| \\__| \\___| |_|");
System.out.println(" |___/");
System.out.println(" Version v" + version + " Last updated at " + date + "");
System.out.println(" Developed by Gimleux, Valentin, Open-Schnick.");
System.out.println(" Development Blog: https://blog.filefighter.de");
System.out.println(" The code can be found at: https://www.github.com/filefighter");
System.out.println(" Running on http://localhost:" + serverPort);
System.out.println();
System.out.println("-------------------------------< REST API >-------------------------------");
System.out.println();
Expand Down Expand Up @@ -83,19 +84,31 @@ CommandLineRunner initDataBaseProd(UserRepository userRepository, FileSystemRepo
.groupIds(new long[]{0, 1})
.build()));

log.info("Preloading default fsStructure: {}.", fileSystemRepository.save(FileSystemEntity
.builder()
.createdByUserId(0)
.fileSystemId(0)
.isFile(false)
.path("/")
.itemIds(new long[0])
.lastUpdated(Instant.now().getEpochSecond())
.name("root")
.size(0)
.typeId(FileSystemType.FOLDER.getId())
.visibleForGroupIds(new long[]{-1, 0, 1})
.build()));
log.info("Preloading default fsStructure: {} {}.", fileSystemRepository.save(FileSystemEntity
.builder()
.createdByUserId(0)
.fileSystemId(0)
.isFile(false)
.path("/")
.itemIds(new long[0])
.lastUpdated(Instant.now().getEpochSecond())
.name("root")
.size(0)
.typeId(FileSystemType.FOLDER.getId())
.visibleForGroupIds(new long[]{-1, 0, 1})
.itemIds(new long[]{1})
.build()),
fileSystemRepository.save(FileSystemEntity.builder()
.createdByUserId(0)
.fileSystemId(1)
.isFile(true)
.lastUpdated(Instant.now().getEpochSecond())
.name("dummyFile.txt")
.size(420)
.typeId(FileSystemType.TEXT.getId())
.editableFoGroupIds(new long[]{0})
.visibleForGroupIds(new long[]{0})
.build()));

log.info("Inserting Users {}", (userRepository.findAll().size() == 1 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE));
log.info("Inserting fsItems {}", (fileSystemRepository.findAll().size() == 1 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE));
Expand Down Expand Up @@ -123,7 +136,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo
.lowercaseUsername("user1")
.password("12345")
.refreshToken("rft")
.groupIds(new long[]{-1})
.groupIds(new long[]{0})
.build()));

log.info("Preloading default tokens: {} {}",
Expand All @@ -140,22 +153,33 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo
.validUntil(Instant.now().getEpochSecond() + AccessTokenBusinessService.ACCESS_TOKEN_DURATION_IN_SECONDS)
.build()));

log.info("Preloading default fsItems: {} {}.",
log.info("Preloading default fsItems: {} {} {}.",
fileSystemRepository.save(FileSystemEntity.builder()
.createdByUserId(0)
.fileSystemId(0)
.isFile(false)
.path("/")
.itemIds(new long[]{1})
.itemIds(new long[]{2})
.lastUpdated(Instant.now().getEpochSecond())
.name("root")
.name("HOME_User")
.size(420)
.typeId(FileSystemType.FOLDER.getId())
.visibleForGroupIds(new long[]{0, 1})
.build()),
fileSystemRepository.save(FileSystemEntity.builder()
.createdByUserId(1)
.fileSystemId(1)
.isFile(false)
.path("/")
.lastUpdated(Instant.now().getEpochSecond())
.name("HOME_User1")
.size(420)
.typeId(FileSystemType.FOLDER.getId())
.visibleForGroupIds(new long[]{-1, 0, 1})
.build()),
fileSystemRepository.save(FileSystemEntity.builder()
.createdByUserId(0)
.fileSystemId(1)
.fileSystemId(2)
.isFile(true)
.lastUpdated(Instant.now().getEpochSecond())
.name("dummyFile.txt")
Expand All @@ -165,7 +189,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo
.visibleForGroupIds(new long[]{0})
.build()));

log.info("Inserting FileSystemItems {}", (fileSystemRepository.findAll().size() == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE));
log.info("Inserting FileSystemItems {}", (fileSystemRepository.findAll().size() == 3 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE));
log.info("Inserting token {}", (accessTokenRepository.findAll().size() == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE));
log.info("Inserting Users {}", (userRepository.findAll().size() == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class RestConfiguration {
public static final String DEFAULT_ERROR_URI = "/error";

private RestConfiguration(){
// Cannot be inst
// Cannot be instantiated.
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.filefighter.rest.domain.common;

public interface DtoServiceInterface<D,E> {
public interface DTOServiceInterface<D,E> {
D createDto(E entity);
E findEntity(D dto);
}
Loading