-
Notifications
You must be signed in to change notification settings - Fork 14
US87141: Added JPA Entities for AttributeConnector and AttributeAdapterConnection #92
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
| @Column(name = "adapter_endpoint", nullable = false) | ||
| private String adapterEndpoint; | ||
|
|
||
| @Column(name = "adapter_token_url", nullable = false) |
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.
Possibly see if you can move annotations as applicable from fields to getters
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.
See other related comment,
| this.adapterClientSecret = uaaClientSecret; | ||
| } | ||
|
|
||
| public AttributeAdapterConnectionEntity() { |
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.
Do we need this? if needed can we make it private since we dont have setters?
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.
It needs to be public if we have the @entity annotation
| @Table(name = "attribute_connector") | ||
| public class AttributeConnectorEntity { | ||
| @Id | ||
| @Column(name = "id") |
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.
Is is possible to move annotations on getters which I believe is a better practice read stackoverflow or google for more details?
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.
It looks like unit tests are not passing when we make this move.
| private long id; | ||
|
|
||
| @Column(name = "refresh_interval_hours", nullable = true) | ||
| private int refreshIntervalHours; |
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.
Should we do it in seconds?
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.
@sanjeevchopra discussed with me he wanted the field in the ACS API to be in hours so that the minimum time they can pass is 1 hour. Sanjeev, what do you think? We could:
- Change customer field in the public API to be in seconds
- Convert from hours to seconds when we store in the DB
- Keep it the way it is
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.
lets discuss
- I suggested this to force a minimum cache time of 1 hour as a design pre-req.
- To provide flexibility, we can use minutes and enforce a minimum of 60 mins. In case someone doesn't care about latency. Default should be probably 8 hours.
- on a side not
maxCacheIntervalMintuesmaybe more clear as a name
| @JoinColumn(name = "connector_id", referencedColumnName = "id", nullable = false, updatable = false) | ||
| private AttributeConnectorEntity connector; | ||
|
|
||
| @Column(name = "adapter_endpoint", nullable = false) |
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.
Looks like we have not specified length for the endpoint, please check other fields as well.
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.
Added length of 128
| adapter_client_id varchar(128) NOT NULL | ||
| ); | ||
|
|
||
| ALTER TABLE authorization_zone ADD COLUMN resource_attribute_connector integer NULL; |
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 column should be same type as the one it links to - attribute_connector(id)
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.
Agreed that foreign keys must have the same type of the referenced column's type. However, for postgres attribute_connector(id) is defined as bigserial. We can't use this type when defining a nullable foreign key for zone entity as bigserial does not support nullability. Since bigserial is just a wrapper for bigint to support auto-generating sequencing, decided to use bigint for foreign key definition.
|
|
||
| ALTER TABLE authorization_zone ADD COLUMN resource_attribute_connector integer NULL; | ||
| ALTER TABLE authorization_zone ADD FOREIGN KEY (resource_attribute_connector) REFERENCES attribute_connector(id) ON DELETE CASCADE; | ||
| ALTER TABLE authorization_zone ADD COLUMN subject_attribute_connector integer NULL; |
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.
same as above
| private long id; | ||
|
|
||
| @Column(name = "refresh_interval_hours", nullable = true) | ||
| private int refreshIntervalHours; |
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.
lets discuss
- I suggested this to force a minimum cache time of 1 hour as a design pre-req.
- To provide flexibility, we can use minutes and enforce a minimum of 60 mins. In case someone doesn't care about latency. Default should be probably 8 hours.
- on a side not
maxCacheIntervalMintuesmaybe more clear as a name
| return this.refreshIntervalHours; | ||
| } | ||
|
|
||
| public Set<AttributeAdapterConnectionEntity> getAttributeAdapters() { |
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.
getAttributeAdapterConnections ?
| @JoinColumn(name = "connector_id", referencedColumnName = "id", nullable = false, updatable = false) | ||
| private AttributeConnectorEntity connector; | ||
|
|
||
| @Column(name = "adapter_endpoint", nullable = false, length = 128) |
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.
128 seems small - please double check other urls we store in acs/uaa. 256 ?
| return adapterClientId; | ||
| } | ||
|
|
||
| public String getUaaClientSecret() { |
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.
Pls add a note here that this is temporary until encryption is implemented.
| @EnableAutoConfiguration | ||
| @ContextConfiguration(classes = { InMemoryDataSourceConfig.class }) | ||
| @ActiveProfiles(resolver = TestActiveProfilesResolver.class) | ||
| public class ZoneRepositoryTest extends AbstractTransactionalTestNGSpringContextTests { |
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.
Consider any negative tests - missing required fields in adapter, field too long etc. Some may belong at the controller layer to assert the correct response codes.
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.
We were thinking that this would be enforced at the controller level. In the rest api story we already have one test for this, and will add more.
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.
ok, once you squash the commits I can merge
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.
Ok it's good to go. Integration tests are passing locally (Jenkins tests won't pass because of connections issues). Please merge so that we can continue with Rest API story.
…erConnection Signed-off-by: Irina <[email protected]>
Signed-off-by: Irina [email protected]