Conversation
There was a problem hiding this comment.
Hey. Thanks for your contribution! Overall it looks good. Apart from the comments I left you, I'll need 2 big things:
- Please keep the main purpose of the PR and remove the refactor of the
Requestcreation and handling. You can move those commits to a separate PR if you want, but they add noise here. - Please add the missing tests as some endpoints are not tested.
Once assorted, I'll carefully check each endpoint against the server to see if we're missing any required parameters.
Cheers
.gitignore
Outdated
| .idea/sqlDataSources.xml | ||
| .idea/dynamic.xml | ||
| .idea/uiDesigner.xml | ||
| /.idea/ |
There was a problem hiding this comment.
We decided to keep some of the idea files, by using the "intellij+iml" configuration provided by gitignore.io. Remove this line please.
| } | ||
|
|
||
| @Override | ||
| public String toString() { |
There was a problem hiding this comment.
Remove this method as we chose not to provide it on the other entities.
| } | ||
|
|
||
| @Override | ||
| public String toString() { |
There was a problem hiding this comment.
Remove this method as we chose not to provide it on the other entities.
| import static org.hamcrest.Matchers.notNullValue; | ||
| import static org.junit.Assert.assertThat; | ||
|
|
||
| public class ResourceServerEntityTest extends BaseMgmtEntityTest { |
There was a problem hiding this comment.
More tests should be added to cover all the new methods.
| @JsonProperty("is_system") | ||
| private Boolean isSystem; | ||
|
|
||
| public ResourceServer() { |
There was a problem hiding this comment.
I don't remember if this constructor must exist because of Jackson, see if it can be removed. Also we need a constructor that receives at least the identifier parameter as that's the only required parameter when creating a new ResourceServer instance to post. id will always be returned by the server, but I trust Jackson is going to handle it just fine 😄 . (Add those tests)
There was a problem hiding this comment.
Default constructor removed.
As I understand JSON transformation is covered in ResourceServerEntityTest when content of resource_servers_list.json is converted to ResourceServer instances. Do we nee additional tests for JSON conversion?
| * Cretes request for fetching single resource server by it's ID. | ||
| * See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers_by_id>API documentation</a> | ||
| * | ||
| * @param id {@link ResourceServer#identifier} field |
There was a problem hiding this comment.
id and identifier are different properties of a ResourceServer. My guess is that the id is the one the server assigns when it's created, and the identifier is the name we choose for it (like "myapp.auth0.com"). An identifier is required when creating the ResourceServer while the id is always returned when listing/getting resource servers.
| * @param id {@link ResourceServer#identifier} field | ||
| * @return request to execute | ||
| */ | ||
| public Request<ResourceServer> get(String id) { |
There was a problem hiding this comment.
Rename to resourceServerId
| * @param id {@link ResourceServer#identifier} field | ||
| * @return request to execute | ||
| */ | ||
| public Request<Void> delete(String id) { |
There was a problem hiding this comment.
Rename to resourceServerId
86e8997 to
3a3b9a7
Compare
|
|
3a3b9a7 to
801209c
Compare
|
|
There was a problem hiding this comment.
@mfarsikov Thanks. Like I said, feel free to submit those improvements in a separate PR and I'll review them in the future. I've some new feedback for you:
- Test setters as coverage complains you're not testing them.
- I've doubts with
verificationKeyandverificationLocationand can't make the server return them, maybe they are just set on creation. I'll ask the team to verify they are correct. Edit: Added a comment to remove theverificationKeyproperty.
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| public class Scope { |
There was a problem hiding this comment.
Add these annotations at the class level
@SuppressWarnings("WeakerAccess", "unused")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)| private Boolean allowOfflineAccess; | ||
| @JsonProperty("skip_consent_for_verifiable_first_party_clients") | ||
| private Boolean skipConsentForVerifiableFirstPartyClients; | ||
| @JsonProperty("token_lifetime") |
There was a problem hiding this comment.
It's missing the "token_lifetime_for_web" property.
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class ResourceServer { | ||
| @JsonProperty |
There was a problem hiding this comment.
add the explicit property name in the annotation
| public class ResourceServer { | ||
| @JsonProperty | ||
| private String id; | ||
| @JsonProperty |
There was a problem hiding this comment.
add the explicit property name in the annotation
| @JsonProperty("scopes") | ||
| private List<Scope> scopes; | ||
| @JsonProperty("signing_alg") | ||
| private String signingAlg; |
There was a problem hiding this comment.
rename to signingAlgorithm (same for getters/setters)
| } | ||
|
|
||
| @JsonCreator | ||
| public ResourceServer(@JsonProperty("id") String id, |
There was a problem hiding this comment.
Remove this constructor as the only required field is "identifier". Add another one with no-args, since when you need to PATCH the resource server you can't specify the "identifier".
| @JsonProperty("is_system") | ||
| private Boolean isSystem; | ||
|
|
||
| public ResourceServer(String identifier) { |
There was a problem hiding this comment.
Annotate this constructor with @JsonCreator and add the @JsonProperty annotation to the "identifier" parameter.
| return identifier; | ||
| } | ||
|
|
||
| public void setIdentifier(String identifier) { |
There was a problem hiding this comment.
Remove this setter as it cannot change.
| this.name = name; | ||
| } | ||
|
|
||
| public Boolean getIsSystem() { |
| private String value; | ||
|
|
||
| @JsonCreator | ||
| public Scope(@JsonProperty("value") String value, |
There was a problem hiding this comment.
Value is the only required property. Let's have a single constructor with value instead of both.
| @JsonProperty("token_lifetime") | ||
| private Integer tokenLifetime; | ||
| @JsonProperty("verificationKey") | ||
| private String verificationKey; |
| return isSystem; | ||
| } | ||
|
|
||
| public void setIsSystem(Boolean system) { |
There was a problem hiding this comment.
Remove setter as I'm not sure this works. It's easier to add it later 👍
| * @param resourceServerId {@link ResourceServer#id} field | ||
| * @return request to execute | ||
| */ | ||
| public Request<ResourceServer> get(String resourceServerId) { |
There was a problem hiding this comment.
All these entity methods that have a resourceServerId as a parameter, I'm checking the API docs and it says that it could be either the id or the identifier (audience) value. Assert this is true and in that case, rename to resourceServerIdOrIdentifier and explain this in the javadoc.
|
Regarding testing setters: I would not recommend to create "cargo cult" around test-coverage. I not sure but it should be possible to exclude data-classes from coverage testing. Thank you for your patience :) |
lbalmaceda
left a comment
There was a problem hiding this comment.
I agree with your comment about the test coverage but in this case, the serialization is not being tested completely neither in the client not in the pojo tests. I decided to make simpler the tests on the client by just checking the body size (in parameters count) and test the serialization in a separate pojo test, because jackson uses annotations to handle this. I've left you some final comments. Thanks
| private List<Scope> scopes; | ||
| @JsonProperty("signing_alg") | ||
| private String signingAlg; | ||
| @JsonProperty("signing_algorithm") |
There was a problem hiding this comment.
the json property was correct signing_alg, what changes is the pojo field name (the line below)
|
|
||
| public String getSigningAlg() { | ||
| return signingAlg; | ||
| @JsonProperty("signing_algorithm") |
There was a problem hiding this comment.
Remember to also fix this json property name.
|
|
||
| public void setSigningAlg(String signingAlg) { | ||
| this.signingAlg = signingAlg; | ||
| @JsonProperty("signing_algorithm") |
| @Test | ||
| public void shouldUpdateResourceServer() throws Exception { | ||
| ResourceServer resourceServer = new ResourceServer("https://api.my-company.com/api/v2/"); | ||
| resourceServer.setId("23445566abab"); |
There was a problem hiding this comment.
Just keep the new instance line, the pojo class serialization should be tested in a separate file as we did for the rest of them. The scope description serialization for example is never tested. Check the test/com/auth0/json/mgmt folder for examples and please add one class for each pojo. You can remove the call to the setters on this "shouldUpdateResourceServer" test.
4cbb7cf to
d1d09cd
Compare
|
BTW: serialization test revealed a bug 👍 |
|
Please let me know if this time it is ok - I will squash commits |
|
@mfarsikov Thanks for the contribution. I'll prepare a minor release with these changes. 🎉 |
Added
Resource serverCRUDFor ease building requests
RequestBuilderwas added, and refactored already existed Entities to use it.(Resource server API doc)