Skip to content

Commit

Permalink
SHIBUI-2596
Browse files Browse the repository at this point in the history
Fixing unit tests and startup without a default value for beacon cron. Renamed property for beacon cron frmo code review feedback
  • Loading branch information
chasegawa committed Jul 12, 2023
1 parent 1638c4e commit 352b321
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/src/main/app-resources/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
## Only set the installationID if you wish to define the ID used by the beacon. RECOMMENDED: ignore - a default random value will be used
## Only change the urls if instructed or if you wish to redirect for testing (if multiple, separate list with commas
## Only change the productName for testing purposes
## Set the cron time to send the beacon data at a specific time - if unset, the system will send at a random time between 12AM and 4AM once per day
## Set the cron time to send the beacon data at a specific time - if unset, the system will send at a random time between 12AM and 4AM once per day (random preferred)
# beacon:
# enabled: ture
# installationID: [user-defined value]
# urls: http://collector.testbed.tier.internet2.edu:5001
# productName: ShibUI
# send:
# cron: 0 4 * * * *
# cron: 0 59 3 * * ?

# pac4j-enabled: true
# pac4j:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import edu.internet2.tier.shibboleth.admin.util.EntityDescriptorConversionUtils;
import edu.internet2.tier.shibboleth.admin.util.LuceneUtility;
import edu.internet2.tier.shibboleth.admin.util.ModelRepresentationConversions;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
Expand Down Expand Up @@ -277,7 +276,7 @@ public LockProvider lockProvider(DataSource dataSource) {
}

@Bean
public String getBeaconCronValue(BeaconConfigurationRepository repo)
public String getBeaconCronValue(BeaconConfigurationRepository repo, @Value("${shibui.beacon.send.cron:nodefault}") String valueFromConfig)
{
Optional<BeaconConfiguration> obc = repo.findById(1);
BeaconConfiguration bc;
Expand All @@ -286,8 +285,16 @@ public String getBeaconCronValue(BeaconConfigurationRepository repo)
BeaconConfiguration newbc = new BeaconConfiguration();
Random rand = new Random();
String cron = "0 " + rand.nextInt(60) + " " + rand.nextInt(4) + " * * ?";
if (valueFromConfig.endsWith("?")) {
cron = valueFromConfig;
}
newbc.setSendCron(cron);
repo.save(newbc);
try {
repo.save(newbc);
}
catch(Exception e) {
log.debug("Error trying to create new BEACON CRON - should be ok");
}
bc = repo.findById(1).get();
} else {
bc = obc.get();
Expand Down
5 changes: 3 additions & 2 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ shibui.beacon.enabled=true
shibui.beacon.productName=ShibUi
shibui.beacon.installationID=UNICON-SHIBUI-TESTING
shibui.beacon.url=http://collector.testbed.tier.internet2.edu:5001
#shibui.beacon.send.cron=0 59 3 * * ?

### Swagger/Springdoc patterns
springdoc.use-management-port=true
Expand All @@ -137,5 +138,5 @@ management.server.port=9090
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.allowed-headers=*

### Lucene temp dir location to use
shibui.lucene.dir=/var/tmp/shibui-cache
# When true, this will remove the validUntil attribute for an EntityDescriptor uploaded from XML source, only set to false if you want the XML uploaded as is
# shibui.remove.EntityDescriptor.validUntil=true

0 comments on commit 352b321

Please sign in to comment.