-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -11,3 +11,8 @@ gradle-app.setting | |
out/ | ||
classes/ | ||
.idea_modules/ | ||
|
||
### Eclipse stuff | ||
.project | ||
.settings | ||
.classpath |
This file contains 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
37 changes: 37 additions & 0 deletions
37
riposte-spi/src/main/java/com/nike/riposte/server/error/exception/Forbidden403Exception.java
This file contains 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,37 @@ | ||
/** | ||
* | ||
*/ | ||
package com.nike.riposte.server.error.exception; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.nike.internal.util.Pair; | ||
|
||
/** | ||
* Thrown when a request does not have a valid authorization header. Represents a HTTP 403 response code. | ||
* | ||
* @author pevans | ||
* | ||
*/ | ||
public class Forbidden403Exception extends RuntimeException { | ||
|
||
public final String requestPath; | ||
public final String authorizationHeader; | ||
public final List<Pair<String, String>> extraDetailsForLogging; | ||
|
||
public Forbidden403Exception(String message, String requestPath, String authorizationHeader) { | ||
this(message, requestPath, authorizationHeader, new ArrayList<>()); | ||
} | ||
|
||
public Forbidden403Exception(String message, String requestPath, String authorizationHeader, | ||
List<Pair<String, String>> extraDetailsForLogging) { | ||
super(message); | ||
|
||
this.requestPath = requestPath; | ||
this.authorizationHeader = authorizationHeader; | ||
this.extraDetailsForLogging = extraDetailsForLogging; | ||
} | ||
private static final long serialVersionUID = 4921880566299500314L; | ||
|
||
} |
This file contains 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
32 changes: 32 additions & 0 deletions
32
...-spi/src/test/java/com/nike/riposte/server/error/exception/Forbidden403ExceptionTest.java
This file contains 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,32 @@ | ||
package com.nike.riposte.server.error.exception; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import java.util.UUID; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class Forbidden403ExceptionTest { | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
} | ||
|
||
@Test | ||
public void should_honor_constructor_params() { | ||
//given | ||
String requestPath = UUID.randomUUID().toString(); | ||
String authorizationHeader = UUID.randomUUID().toString(); | ||
String message = UUID.randomUUID().toString(); | ||
|
||
//when | ||
Forbidden403Exception ex = new Forbidden403Exception(message, requestPath, authorizationHeader); | ||
|
||
//then | ||
assertThat(ex.getMessage(), is(message)); | ||
assertThat(ex.requestPath, is(requestPath)); | ||
assertThat(ex.authorizationHeader, is(authorizationHeader)); | ||
} | ||
|
||
} |