Skip to content

Improve OAuth2 Resource Server tests #7118

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

Closed
henriquels25 opened this issue Jul 20, 2019 · 2 comments · Fixed by #7159
Closed

Improve OAuth2 Resource Server tests #7118

henriquels25 opened this issue Jul 20, 2019 · 2 comments · Fixed by #7159
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Milestone

Comments

@henriquels25
Copy link
Contributor

Summary

The tests for the OAuth2 Resource Server sample only include GET requests.

I believe it would be useful to add examples for other HTTP methods (POST, PUT, PATCH, DELETE) because the code for testing them is different.

Sample

In this project it's possible to see that if the same technique used for testing the GET requests is used for a POST, the test fails without sending the CSRF token in the request.

In this example, I created a working POST request test example based on the sample, based on the explanation contained on this StackOverflow question.

@henriquels25 henriquels25 changed the title Improve OAuth2 Resource server tests Improve OAuth2 Resource Server tests Jul 20, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 20, 2019
@jzheaux
Copy link
Contributor

jzheaux commented Jul 22, 2019

@henriquels25 I agree that additional tests would be helpful; would you be interested in submitting a PR?

@jzheaux jzheaux self-assigned this Jul 22, 2019
@jzheaux jzheaux added in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 22, 2019
@jzheaux jzheaux added this to the 5.2.0.M4 milestone Jul 22, 2019
@henriquels25
Copy link
Contributor Author

@jzheaux I submitted a PR with examples for a POST request. I didn't create examples for the other HTTP methods to keep the sample small, as the code for testing them is not different.

henriquels25 added a commit to henriquels25/spring-security that referenced this issue Aug 1, 2019
- Add a post endpoint in /messages
- Changes the security config to require the read scope to GET a message and the write scope
to POST a new message.
- Changes the jwks of the mock server so I could create a new access token with the write scope.
- Creates tests and integration-tests for the POST endpoint.
- Changes the README to add an example of a POST request.

Fixes spring-projectsgh-7118
@jzheaux jzheaux modified the milestones: 5.2.0.M4, 5.2.0.RC1 Aug 5, 2019
jzheaux pushed a commit that referenced this issue Aug 6, 2019
- Add a post endpoint in /messages
- Changes the security config to require the read scope to GET a message and the write scope
to POST a new message.
- Changes the jwks of the mock server so I could create a new access token with the write scope.
- Creates tests and integration-tests for the POST endpoint.
- Changes the README to add an example of a POST request.

Fixes gh-7118
kostya05983 pushed a commit to kostya05983/spring-security that referenced this issue Aug 26, 2019
- Add a post endpoint in /messages
- Changes the security config to require the read scope to GET a message and the write scope
to POST a new message.
- Changes the jwks of the mock server so I could create a new access token with the write scope.
- Creates tests and integration-tests for the POST endpoint.
- Changes the README to add an example of a POST request.

Fixes spring-projectsgh-7118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants