-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defaultrefererfix #976
Merged
Merged
Defaultrefererfix #976
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fa7065c
fixed referer retrieval bug (if the context path string was present in
valeriolopes f41182d
fixed referer retrieval bug - if the context path string was present in
valeriolopes 93b9a96
Revert "fixed referer retrieval bug - if the context path string was …
valeriolopes 3f05d6f
Revert "fixed referer retrieval bug (if the context path string was p…
valeriolopes 602c752
Fix referer retrieval bug
valeriolopes cecb90e
Enhancement on referer retrieval
valeriolopes 4000248
Relaxing getReferer() visibility to 'protected' in order to unit test it
valeriolopes 790f496
Enhancing getReferer for specific cases; Breaking down getReferer test
valeriolopes ee94e2e
Removing comments; renaming method to have it following the others name
valeriolopes 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 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 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
import static br.com.caelum.vraptor.view.Results.logic; | ||
import static br.com.caelum.vraptor.view.Results.page; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.mock; | ||
|
@@ -150,4 +151,24 @@ public void whenRefererMatchesAControllerShouldForwardToIt() throws Exception { | |
verify(logic).forwardTo(RefererController.class); | ||
verify(controller).index(); | ||
} | ||
|
||
@Test | ||
public void getRefererShouldReturnCorrectValue() throws Exception { | ||
when(request.getHeader("Referer")).thenReturn("http://vraptor.caelum.com.br/test/anything/ok"); //Regular case | ||
when(request.getContextPath()).thenReturn("/test"); | ||
assertEquals("/anything/ok", refererResult.getReferer()); | ||
|
||
when(request.getHeader("Referer")).thenReturn("http://vraptor.caelum.com.br/anything/ok/test"); //URL without context path (it appears in the path but not in in the right place) | ||
when(request.getContextPath()).thenReturn("/test"); | ||
assertEquals("/anything/ok/test", refererResult.getReferer()); | ||
|
||
when(request.getHeader("Referer")).thenReturn("http://vraptor.caelum.com.br/vrap/anything/ok"); //URL host starts with ctx path string (/vrap) | ||
when(request.getContextPath()).thenReturn("/vrap"); | ||
assertEquals("/anything/ok", refererResult.getReferer()); | ||
|
||
when(request.getHeader("Referer")).thenReturn("/vrap/anything/ok/vrap"); //relative path in the referer (not common but predicted by http spec) | ||
when(request.getContextPath()).thenReturn("/vrap"); | ||
assertEquals("/anything/ok/vrap", refererResult.getReferer()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. split this test into 4 |
||
} | ||
|
||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can drop the comments on all tests,
then 🚢