Skip to content
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

FIX RefererResult bug #975

Closed
wants to merge 7 commits into from
Closed

Conversation

valeriolopes
Copy link
Collaborator

When retrieving the http referer, vraptor uses the substring method to identify the beggining of the context path. If the context path appears in the URL host the return is invalid.
Example: http://application.code.com/app/test/

VRaptor will search '/app' in the URL and will find http://application.code.com/app.test and return /application.code.com/app/test and not /app/test as expected.

the url host an invalid referer was returned)
the referer host an invalid referer was returned
If the context path string was present in the referer host, the
getReferer() method returned an invalid referer
On proxied app servers is common to have the context path suppressed
from the external URL, although it is still valid within the app server
context. If the request referer path does not start with the internal
context, it should return the entire path.

verify(logic).forwardTo(RefererController.class);
verify(controller).index();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much context to execute a simple check. Maybe it's better to relax visibility of getReferer() to protected and test only this method, what do you think?

and we get an extra extension point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that was my first commit on VRaptor so I tried to write comprehensive unit tests :-) - but I agree it's too much for something so simple. In addition it's a hard condition to achieve, the strings must match in a little-prob coincidence.

About the extension point, I don't have an opinion - would you expect this class to be extended? If so, then yes it's a good way to maintain its structure (or else people would have to create another method to perform this check, or even put its code within the callers)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your tests are fine =)

it's just that this test class has several tests that could be testing only getReferer(), not the whole redirect or forward methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I followed the other methods pattern but we could have simple tests which would check if the returned string matches the expected value and we're good to go. Wanna me to change that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please @valeriolopes! After that change we can merge this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up creating another pull request (976); I really need to stop and play with git (we still use svn here). The changes are there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @valeriolopes. So I think we close this PR, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like the other one embraces everything

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap! thks

@valeriolopes
Copy link
Collaborator Author

You're right, I followed the other methods pattern but we could have simple tests which would check if the returned string matches the expected value and we're good to go. Wanna me to change that?

@Turini Turini closed this Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants