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 4b59d26 commit 00df9bd
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 75 deletions.
3 changes: 2 additions & 1 deletion backend/src/main/app-resources/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
# installationID: [user-defined value]
# urls: http://collector.testbed.tier.internet2.edu:5001
# productName: ShibUI
# cron: 0 59 3 * * ?
# send:
# cron: 0 59 3 * * ?

# pac4j-enabled: true
# pac4j:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public LockProvider lockProvider(DataSource dataSource) {
}

@Bean
public String getBeaconCronValue(BeaconConfigurationRepository repo, @Value("${shibui.beacon.cron}") String valueFromConfig)
public String getBeaconCronValue(BeaconConfigurationRepository repo, @Value("${shibui.beacon.send.cron:nodefault}") String valueFromConfig)
{
Optional<BeaconConfiguration> obc = repo.findById(1);
BeaconConfiguration bc;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,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.cron=0 59 3 * * ?
#shibui.beacon.send.cron=0 59 3 * * ?

### Swagger/Springdoc patterns
springdoc.use-management-port=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResour
/**
* @author Dmitriy Kopylenko
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName", "shibui.beacon.cron=0 3 3 * * ?"])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles(["no-auth", "badjson"])
class BadJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Specification {

Expand All @@ -48,11 +48,6 @@ class BadJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Speci
@TestConfiguration
@Profile('badjson')
static class Config {
@Bean
public String getBeaconCronValue() {
return "0 3 3 * * ?";
}

@Bean
JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(ResourceLoader resourceLoader, ObjectMapper jacksonMapper) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ package edu.internet2.tier.shibboleth.admin.ui.controller
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Import
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName", "shibui.beacon.cron=0 3 3 * * ?"])
@Import([LocalConfig.class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles(["no-auth", "dev"])
class EntityDescriptorControllerSchemaValidationIntegrationTests extends Specification {

Expand Down Expand Up @@ -54,13 +51,4 @@ class EntityDescriptorControllerSchemaValidationIntegrationTests extends Specifi
private static HttpEntity<String> createRequestHttpEntityFor(Closure jsonBodySupplier) {
new HttpEntity<String>(jsonBodySupplier(), ['Content-Type': 'application/json'] as HttpHeaders)
}

@org.springframework.boot.test.context.TestConfiguration
private static class LocalConfig {
@Bean
public String getBeaconCronValue() {
return "0 3 3 * * ?";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ package edu.internet2.tier.shibboleth.admin.ui.controller
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Import
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

/**
* @author Dmitriy Kopylenko
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName", "shibui.beacon.cron=0 3 3 * * ?"])
@Import([LocalConfig.class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles("no-auth")
class GoodJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Specification {

Expand All @@ -29,12 +26,4 @@ class GoodJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Spec
result.statusCodeValue == 200
result.body.properties.entityId.title == 'label.entity-id'
}

@org.springframework.boot.test.context.TestConfiguration
private static class LocalConfig {
@Bean
public String getBeaconCronValue() {
return "0 3 3 * * ?";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import static org.springframework.http.HttpMethod.PUT
/**
* @author Dmitriy Kopylenko
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health",
"shibui.beacon.productName=shibuiProdName",
"shibui.beacon.cron=0 3 3 * * ?"])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles(["no-auth", "mfci-test"])
class MetadataFiltersControllerIntegrationTests extends Specification {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverReposit
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Import
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName", "shibui.beacon.cron=0 3 3 * * ?"])
@Import([LocalConfig.class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles(["no-auth", "dev"])
class MetadataFiltersControllerSchemaValidationIntegrationTests extends Specification {

Expand Down Expand Up @@ -102,12 +99,4 @@ class MetadataFiltersControllerSchemaValidationIntegrationTests extends Specific
private static resourceUriFor(String uriTemplate, String resourceId) {
String.format(uriTemplate, resourceId)
}

@org.springframework.boot.test.context.TestConfiguration
private static class LocalConfig {
@Bean
public String getBeaconCronValue() {
return "0 3 3 * * ?";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package edu.internet2.tier.shibboleth.admin.ui.controller


import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverRepository
import edu.internet2.tier.shibboleth.admin.ui.util.TestObjectGenerator
import edu.internet2.tier.shibboleth.admin.util.AttributeUtility
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Import
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

/**
* @author Dmitriy Kopylenko
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName", "shibui.beacon.cron=0 3 3 * * ?"])
@Import([LocalConfig.class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health", "shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles("no-auth")
class MetadataFiltersPositionOrderControllerIntegrationTests extends Specification {

Expand Down Expand Up @@ -149,12 +145,4 @@ class MetadataFiltersPositionOrderControllerIntegrationTests extends Specificati
private static resourceUriFor(String resolverResourceId) {
String.format(RESOURCE_URI, resolverResourceId)
}

@org.springframework.boot.test.context.TestConfiguration
private static class LocalConfig {
@Bean
public String getBeaconCronValue() {
return "0 3 3 * * ?";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ package edu.internet2.tier.shibboleth.admin.ui.controller
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Import
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["management.endpoints.web.exposure.include=info, health",
"shibui.beacon.productName=shibuiProdName",
"shibui.beacon.cron=0 3 3 * * ?"])
@Import([LocalConfig.class])
"shibui.beacon.productName=shibuiProdName"])
@ActiveProfiles(["no-auth", "dev"])
class MetadataResolverControllerSchemaValidationIntegrationTests extends Specification {

Expand Down Expand Up @@ -151,12 +147,4 @@ class MetadataResolverControllerSchemaValidationIntegrationTests extends Specifi
private static HttpEntity<String> createRequestHttpEntityFor(String jsonBody) {
new HttpEntity<String>(jsonBody, ['Content-Type': 'application/json'] as HttpHeaders)
}

@org.springframework.boot.test.context.TestConfiguration
private static class LocalConfig {
@Bean
public String getBeaconCronValue() {
return "0 3 3 * * ?";
}
}
}

0 comments on commit 00df9bd

Please sign in to comment.