-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Added Unit Tests For oauth2-core #4499
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
Conversation
This commit contains unit tests for Oauth2-Core.
This commit fixes behavior according to unit tests.
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.
@luander The tests look great. There are a couple of minor updates I'm requesting. After you update I'll merge. Thanks!
@@ -28,6 +29,7 @@ | |||
private String code; | |||
private String clientId; | |||
private String redirectUri; | |||
private AuthorizationGrantType grantType; |
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.
The grant type member is not needed here as it's implied based on the class name -> AuthorizationCodeTokenRequestAttributes
. Can you remove this please.
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void buildWhenClientIdIsNotCalledThenThrowIllegalArgumentException() { |
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.
Please rename to buildWhenClientIdNotSetThenThrowIllegalArgumentException
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void buildWhenRedirectUriIsNotCalledThenThrowIllegalArgumentException() { |
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.
Please rename to buildWhenRedirectUriNotSetThenThrowIllegalArgumentException
} | ||
|
||
@Test | ||
public void buildWhenGetGrantTypeIsCalledThenReturnAuthorizationCodeString() { |
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.
This can be removed based on previous comment
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void buildWhenAuthorizeUriIsNotCalledThenThrowIllegalArgumentException() { |
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.
Please rename to buildWhenAuthorizeUriNotSetThenThrowIllegalArgumentException
} | ||
|
||
@Test | ||
public void buildWhenStateIsNotCalledThenDoesNotThrowAnyException() { |
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.
Please rename to buildWhenStateNotSetThenDoesNotThrowAnyException
import org.junit.Test; | ||
|
||
/** | ||
* Tests ${@link ErrorResponseAttributes} |
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.
Please remove $
public class ErrorResponseAttributesTest { | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void builderWhenCodeIsNullThenThrowIllegalArgumentException() { |
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.
Please rename to withErrorCodeWhenCodeIsNullThenThrowIllegalArgumentException
import java.util.Collections; | ||
|
||
/** | ||
* Tests ${@link TokenResponseAttributes} |
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.
Please remove $
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void buildWhenTokeTypeIsNotCalledThenThrowIllegalArgumentException() { |
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.
Please rename to buildWhenTokenTypeNotSetThenThrowIllegalArgumentException
Thanks for the feedback @jgrandja |
Thanks for your help in adding these tests @luander. This is now merged to master. |
Thank you for accepting my changes. I want to help more. |
We could definitely use more help especially with writing tests. I'll keep an eye out for your contributions. Thanks again! |
Fixes spring-projectsgh-4499 This commit contains unit tests for the endpoints package in oauth2-core.
I added new tests for the oauth2-core according to the oauth 2 RFC 6749.
These tests are only for the "endpoint" package. Other tests may be added/required.
In this PR I also included some fixes for the classes tested.
Part of #4298