Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
Signed-off-by: Takuya Matsumoto <[email protected]>
  • Loading branch information
TakuyaMatsu committed Jan 6, 2025
1 parent 5f493dd commit 22b0e52
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions servers/zms/conf/zms.properties
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,6 @@ athenz.zms.no_auth_uri_list=/zms/v1/schema
# This property specifies the maximum expiry duration in days for user/service/group.
# The value must be an integer, and the default value is 0.
# If set to 0, it indicates that there is no expiry limit.
#athenz.zms.default_user_expiry_days=0
#athenz.zms.default_service_expiry_days=0
#athenz.zms.default_group_expiry_days=0
#athenz.zms.default_max_user_expiry_days=0
#athenz.zms.default_max_service_expiry_days=0
#athenz.zms.default_max_group_expiry_days=0
6 changes: 3 additions & 3 deletions servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSConsts.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public final class ZMSConsts {
public static final String ZMS_PROP_DOMAIN_ENVIRONMENTS = "athenz.zms.domain_environments";
public static final String ZMS_DEFAULT_DOMAIN_ENVIRONMENTS = "production,integration,staging,sandbox,qa,development";

public static final String ZMS_PROP_DEFAULT_USER_EXPIRY = "athenz.zms.default_user_expiry_days";
public static final String ZMS_PROP_DEFAULT_SERVICE_EXPIRY = "athenz.zms.default_service_expiry_days";
public static final String ZMS_PROP_DEFAULT_GROUP_EXPIRY = "athenz.zms.default_group_expiry_days";
public static final String ZMS_PROP_DEFAULT_MAX_USER_EXPIRY = "athenz.zms.default_max_user_expiry_days";
public static final String ZMS_PROP_DEFAULT_MAX_SERVICE_EXPIRY = "athenz.zms.default_max_service_expiry_days";
public static final String ZMS_PROP_DEFAULT_MAX_GROUP_EXPIRY = "athenz.zms.default_max_group_expiry_days";

public static final String ZMS_PROP_VALIDATE_USER_MEMBERS = "athenz.zms.validate_user_members";
public static final String ZMS_PROP_VALIDATE_SERVICE_MEMBERS = "athenz.zms.validate_service_members";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

public class MemberDueDays {

private static final int DEFAULT_USER_EXPIRY = Integer.parseInt(System.getProperty(ZMSConsts.ZMS_PROP_DEFAULT_USER_EXPIRY, "0"));
private static final int DEFAULT_SERVICE_EXPIRY = Integer.parseInt(System.getProperty(ZMSConsts.ZMS_PROP_DEFAULT_SERVICE_EXPIRY, "0"));
private static final int DEFAULT_GROUP_EXPIRY = Integer.parseInt(System.getProperty(ZMSConsts.ZMS_PROP_DEFAULT_GROUP_EXPIRY, "0"));
private static final int DEFAULT_MAX_USER_EXPIRY = Integer.parseInt(System.getProperty(ZMSConsts.ZMS_PROP_DEFAULT_MAX_USER_EXPIRY, "0"));
private static final int DEFAULT_MAX_SERVICE_EXPIRY = Integer.parseInt(System.getProperty(ZMSConsts.ZMS_PROP_DEFAULT_MAX_SERVICE_EXPIRY, "0"));
private static final int DEFAULT_MAX_GROUP_EXPIRY = Integer.parseInt(System.getProperty(ZMSConsts.ZMS_PROP_DEFAULT_MAX_GROUP_EXPIRY, "0"));

final long userDueDateMillis;
final long serviceDueDateMillis;
Expand Down Expand Up @@ -64,9 +64,9 @@ public MemberDueDays(Domain domain, Role role, Type type) {
roleGroupDays = role.getGroupReviewDays();
}

userDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_USER_EXPIRY, domainUserDays, roleUserDays);
serviceDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_SERVICE_EXPIRY, domainServiceDays, roleServiceDays);
groupDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_GROUP_EXPIRY, domainGroupDays, roleGroupDays);
userDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_MAX_USER_EXPIRY, domainUserDays, roleUserDays);
serviceDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_MAX_SERVICE_EXPIRY, domainServiceDays, roleServiceDays);
groupDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_MAX_GROUP_EXPIRY, domainGroupDays, roleGroupDays);
}

public MemberDueDays(Domain domain, Group group) {
Expand All @@ -79,8 +79,8 @@ public MemberDueDays(Domain domain, Group group) {
Integer groupUserDays = group.getMemberExpiryDays();
Integer groupServiceDays = group.getServiceExpiryDays();

userDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_USER_EXPIRY, domainUserDays, groupUserDays);
serviceDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_SERVICE_EXPIRY, domainServiceDays, groupServiceDays);
userDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_MAX_USER_EXPIRY, domainUserDays, groupUserDays);
serviceDueDateMillis = ZMSUtils.configuredDueDateMillis(DEFAULT_MAX_SERVICE_EXPIRY, domainServiceDays, groupServiceDays);
groupDueDateMillis = 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public static boolean metaValueChanged(Object domainValue, Object metaValue) {
return metaValue != null && !metaValue.equals(domainValue);
}

public static long configuredDueDateMillis(Integer serverDefaultDueDateDays, Integer domainDueDateDays, Integer roleDueDateDays) {
public static long configuredDueDateMillis(int serverDefaultDueDateDays, Integer domainDueDateDays, Integer roleDueDateDays) {

// the role expiry days settings overrides the domain one if one configured

Expand All @@ -460,7 +460,7 @@ public static long configuredDueDateMillis(Integer serverDefaultDueDateDays, Int
expiryDays = domainDueDateDays;
}

if (serverDefaultDueDateDays != null && serverDefaultDueDateDays > 0) {
if (serverDefaultDueDateDays > 0) {
if (expiryDays == 0 || expiryDays > serverDefaultDueDateDays) {
expiryDays = serverDefaultDueDateDays;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22953,6 +22953,7 @@ public void testCreateMembershipApprovalNotification() {
public void testGetMemberDueDate() {
ZMSImpl zmsImpl = zmsTestInitializer.getZms();
assertEquals(zmsImpl.getMemberDueDate(100, null), Timestamp.fromMillis(100));
assertEquals(zmsImpl.getMemberDueDate(0, Timestamp.fromMillis(50)), Timestamp.fromMillis(50));
assertEquals(zmsImpl.getMemberDueDate(100, Timestamp.fromMillis(50)), Timestamp.fromMillis(50));
assertEquals(zmsImpl.getMemberDueDate(100, Timestamp.fromMillis(150)), Timestamp.fromMillis(100));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ public void testMetaValueChanged() {
@Test
public void testConfiguredExpiryMillis() {

assertEquals(ZMSUtils.configuredDueDateMillis(null, null, null), 0);
assertEquals(ZMSUtils.configuredDueDateMillis(0, null, null), 0);
assertEquals(ZMSUtils.configuredDueDateMillis(0, null, -3), 0);
assertEquals(ZMSUtils.configuredDueDateMillis(0, null, 0), 0);
Expand Down

0 comments on commit 22b0e52

Please sign in to comment.