This repository was archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/find user #19
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5b45473
Wrote Steps.
open-schnick a50beb7
Fixed advises, added basic exception and advise
open-schnick b4c4404
Changed response messages, fixed feature files
open-schnick 5d6ffbf
Implemented logic for finding users. Fixed some exceptions.
open-schnick 48cd828
Wrote Unit tests, added comment.
open-schnick 2934bac
Added missed Unit Test
open-schnick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 11 additions & 8 deletions
19
src/main/java/de/filefighter/rest/domain/user/data/persistance/UserEntity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
package de.filefighter.rest.domain.user.data.persistance; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
import org.springframework.data.mongodb.core.mapping.MongoId; | ||
|
||
@Document(collection = "user") | ||
@Data | ||
@Getter | ||
@ToString | ||
@Builder | ||
public class UserEntity { | ||
|
||
@MongoId | ||
private String _id; | ||
private long userId; | ||
private String username; | ||
private String password; | ||
private String refreshToken; //TODO: add valid_until for refreshToken | ||
private long[] groupIds; | ||
private final String _id; | ||
private final long userId; | ||
private final String username; | ||
private final String lowercaseUsername; // Redundancy for performance tradeoff. | ||
private final String password; | ||
private final String refreshToken; //TODO: add valid_until for refreshToken | ||
private final long[] groupIds; | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...in/java/de/filefighter/rest/rest/exceptions/RequestDidntMeetFormalRequirementsAdvise.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package de.filefighter.rest.rest.exceptions; | ||
|
||
import de.filefighter.rest.rest.ServerResponse; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ControllerAdvice | ||
public class RequestDidntMeetFormalRequirementsAdvise { | ||
|
||
@ResponseBody | ||
@ExceptionHandler(RequestDidntMeetFormalRequirementsException.class) | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
ResponseEntity<ServerResponse> requestDidntMeetFormalRequirements(RequestDidntMeetFormalRequirementsException ex) { | ||
LoggerFactory.getLogger(RequestDidntMeetFormalRequirementsException.class).warn(ex.getMessage()); | ||
return new ResponseEntity<>(new ServerResponse("denied", ex.getMessage()), HttpStatus.BAD_REQUEST); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...java/de/filefighter/rest/rest/exceptions/RequestDidntMeetFormalRequirementsException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package de.filefighter.rest.rest.exceptions; | ||
|
||
public class RequestDidntMeetFormalRequirementsException extends RuntimeException{ | ||
|
||
public RequestDidntMeetFormalRequirementsException() { | ||
super("Request didnt meet formal requirements."); | ||
} | ||
|
||
public RequestDidntMeetFormalRequirementsException(String message) { | ||
super("Request didnt meet formal requirements. "+message); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/test/java/de/filefighter/rest/cucumber/FindUserSteps.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package de.filefighter.rest.cucumber; | ||
|
||
import de.filefighter.rest.RestApplicationIntegrationTest; | ||
import io.cucumber.java.en.When; | ||
import org.springframework.http.HttpMethod; | ||
|
||
import java.util.HashMap; | ||
|
||
import static de.filefighter.rest.configuration.RestConfiguration.*; | ||
|
||
public class FindUserSteps extends RestApplicationIntegrationTest { | ||
@When("user with accessToken {string} searches user with search-value {string}") | ||
public void userWithAccessTokenSearchesUserWithSearchValue(String accessToken, String search_value) { | ||
String authHeaderString = AUTHORIZATION_BEARER_PREFIX + accessToken; | ||
String url = BASE_API_URI + USER_BASE_URI + "/find?username="+search_value; | ||
|
||
HashMap<String, String> authHeader = new HashMap<>(); | ||
authHeader.put("Authorization", authHeaderString); | ||
|
||
executeRestApiCall(HttpMethod.GET, url, authHeader); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.