diff --git a/pom.xml b/pom.xml index dd751e7..e045a51 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 5.2.35 5.4.7 4.0.13 - 1.6.14 + 1.8.0 2021.0.9 7.0.1 0.52 @@ -168,11 +168,21 @@ org.springframework.cloud spring-cloud-starter-vault-config + + org.springdoc + springdoc-openapi-ui + ${springdoc-openapi-ui.version} + org.springframework.security spring-security-test test + + com.h2database + h2 + test + diff --git a/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/PostgresDBConfig.java b/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/PostgresDBConfig.java new file mode 100644 index 0000000..55ce70e --- /dev/null +++ b/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/PostgresDBConfig.java @@ -0,0 +1,90 @@ +package edu.iu.uits.lms.multiclassmessenger.config; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +@Configuration("MulticlassMessengerDbConfig") +@EnableJpaRepositories( + entityManagerFactoryRef = "MulticlassMessengerEntityMgrFactory", + transactionManagerRef = "MulticlassMessengerTransactionMgr", + basePackages = {"edu.iu.uits.lms.multiclassmessenger.repositories"}) + +@EnableTransactionManagement +public class PostgresDBConfig { + + @Primary + @Bean(name = "MulticlassMessengerDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + public DataSource dataSource(DataSourceProperties properties) { + return properties.initializeDataSourceBuilder().build(); + } + + @Bean(name = "MulticlassMessengerEntityMgrFactory") + @Primary + public LocalContainerEntityManagerFactoryBean multiclassMessengerEntityMgrFactory( + final EntityManagerFactoryBuilder builder, + @Qualifier("MulticlassMessengerDataSource") final DataSource dataSource) { + // dynamically setting up the hibernate properties for each of the datasource. + final Map properties = new HashMap<>(); + return builder + .dataSource(dataSource) + .properties(properties) + .packages("edu.iu.uits.lms.multiclassmessenger.model") + .build(); + } + + @Bean(name = "MulticlassMessengerTransactionMgr") + @Primary + public PlatformTransactionManager multiclassMessengerTransactionMgr( + @Qualifier("MulticlassMessengerEntityMgrFactory") final EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } +} diff --git a/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SecurityConfig.java b/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SecurityConfig.java index a97e9b9..4856dc0 100644 --- a/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SecurityConfig.java +++ b/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SecurityConfig.java @@ -48,6 +48,7 @@ import static edu.iu.uits.lms.lti.LTIConstants.BASE_USER_ROLE; import static edu.iu.uits.lms.lti.LTIConstants.JWKS_CONFIG_URI; +import static edu.iu.uits.lms.lti.LTIConstants.WELL_KNOWN_ALL; @EnableWebSecurity public class SecurityConfig { @@ -64,9 +65,11 @@ protected void configure(HttpSecurity http) throws Exception { http .requestMatchers() .antMatchers(JWKS_CONFIG_URI, "/**/config.json", "/annc/**", "/msg/**") + .antMatchers(WELL_KNOWN_ALL, "/api/**") .and() .authorizeRequests() .antMatchers(JWKS_CONFIG_URI, "/**/config.json").permitAll() + .antMatchers(WELL_KNOWN_ALL, "/api/**").permitAll() .antMatchers("/**").hasRole(BASE_USER_ROLE) .withObjectPostProcessor(new LmsFilterSecurityInterceptorObjectPostProcessor()) .and() diff --git a/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SwaggerConfig.java b/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SwaggerConfig.java new file mode 100644 index 0000000..84cd1e7 --- /dev/null +++ b/src/main/java/edu/iu/uits/lms/multiclassmessenger/config/SwaggerConfig.java @@ -0,0 +1,66 @@ +package edu.iu.uits.lms.multiclassmessenger.config; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import org.springdoc.core.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Profile("swagger") +@Configuration +@OpenAPIDefinition(info = @Info(title = "Multiclass Messenger REST Endpoints", version = "${multiclassmessenger.version}"), + security = @SecurityRequirement(name = "security_auth_multiclassmessenger")) +@SecurityScheme(name = "security_auth_multiclassmessenger", type = SecuritySchemeType.OAUTH2, + flows = @OAuthFlows(authorizationCode = @OAuthFlow( + authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}", + scopes = {@OAuthScope(name = "lms:rest")}, + tokenUrl = "${springdoc.oAuthFlow.tokenUrl}"))) +public class SwaggerConfig { + @Bean + public GroupedOpenApi groupedOpenApi() { + return GroupedOpenApi.builder() + .group("multiclassmessenger") + .packagesToScan("edu.iu.uits.lms.multiclassmessenger.rest") + .build(); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 28c139b..7c6f6d8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -88,9 +88,19 @@ spring: config: activate.on-profile: swagger springdoc: + api-docs: + enabled: true + path: /api/v3/api-docs + cache.disabled: true + packagesToScan: edu.iu.uits.lms.multiclassmessenger.rest swagger-ui: + enabled: false + disable-swagger-default-url: true + path: /api/swagger-ui.html + # Setting supportedSubmitMethods to an empty list is what turns off the "try it out" button + # supportedSubmitMethods: oauth: clientId: ${oauth.tokenprovider.clientId} oAuthFlow: authorizationUrl: ${oauth.tokenprovider.url}/oauth/authorize - tokenUrl: ${oauth.tokenprovider.accessTokenUri} \ No newline at end of file + tokenUrl: ${oauth.tokenprovider.accessTokenUri} diff --git a/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerCustomTest.java b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerCustomTest.java new file mode 100644 index 0000000..2443c92 --- /dev/null +++ b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerCustomTest.java @@ -0,0 +1,50 @@ +package edu.iu.uits.lms.multiclassmessenger.swagger; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import edu.iu.uits.lms.lti.swagger.AbstractSwaggerCustomTest; +import edu.iu.uits.lms.multiclassmessenger.WebApplication; +import edu.iu.uits.lms.multiclassmessenger.config.SecurityConfig; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest(classes = {WebApplication.class, SecurityConfig.class, SwaggerMulticlassMessengerTestConfig.class}) +public class SwaggerCustomTest extends AbstractSwaggerCustomTest { + + @Override + protected List getEmbeddedSwaggerToolPaths() { + return SwaggerTestUtil.getEmbeddedSwaggerToolPaths(super.getEmbeddedSwaggerToolPaths()); + } +} diff --git a/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerDisabledTest.java b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerDisabledTest.java new file mode 100644 index 0000000..74f23bf --- /dev/null +++ b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerDisabledTest.java @@ -0,0 +1,50 @@ +package edu.iu.uits.lms.multiclassmessenger.swagger; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import edu.iu.uits.lms.lti.swagger.AbstractSwaggerDisabledTest; +import edu.iu.uits.lms.multiclassmessenger.WebApplication; +import edu.iu.uits.lms.multiclassmessenger.config.SecurityConfig; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest(classes = {WebApplication.class, SecurityConfig.class, SwaggerMulticlassMessengerTestConfig.class}) +public class SwaggerDisabledTest extends AbstractSwaggerDisabledTest { + + @Override + protected List getEmbeddedSwaggerToolPaths() { + return SwaggerTestUtil.getEmbeddedSwaggerToolPaths(super.getEmbeddedSwaggerToolPaths()); + } +} diff --git a/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerEmbeddedToolTest.java b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerEmbeddedToolTest.java new file mode 100644 index 0000000..289d824 --- /dev/null +++ b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerEmbeddedToolTest.java @@ -0,0 +1,50 @@ +package edu.iu.uits.lms.multiclassmessenger.swagger; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import edu.iu.uits.lms.lti.swagger.AbstractSwaggerEmbeddedToolTest; +import edu.iu.uits.lms.multiclassmessenger.WebApplication; +import edu.iu.uits.lms.multiclassmessenger.config.SecurityConfig; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest(classes = {WebApplication.class, SecurityConfig.class, SwaggerMulticlassMessengerTestConfig.class}) +public class SwaggerEmbeddedToolTest extends AbstractSwaggerEmbeddedToolTest { + + @Override + protected List getEmbeddedSwaggerToolPaths() { + return SwaggerTestUtil.getEmbeddedSwaggerToolPaths(super.getEmbeddedSwaggerToolPaths()); + } +} diff --git a/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerMulticlassMessengerTestConfig.java b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerMulticlassMessengerTestConfig.java new file mode 100644 index 0000000..a6aeba1 --- /dev/null +++ b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerMulticlassMessengerTestConfig.java @@ -0,0 +1,44 @@ +package edu.iu.uits.lms.multiclassmessenger.swagger; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.mock.mockito.MockBean; + +@TestConfiguration +public class SwaggerMulticlassMessengerTestConfig { + @MockBean + private BufferingApplicationStartup bufferingApplicationStartup; +} diff --git a/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerTestUtil.java b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerTestUtil.java new file mode 100644 index 0000000..d1d6702 --- /dev/null +++ b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerTestUtil.java @@ -0,0 +1,44 @@ +package edu.iu.uits.lms.multiclassmessenger.swagger; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import java.util.ArrayList; +import java.util.List; + +public class SwaggerTestUtil { + protected static List getEmbeddedSwaggerToolPaths(List baseList) { + List expandedList = new ArrayList<>(baseList); + return expandedList; + } +} diff --git a/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerUiCustomTest.java b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerUiCustomTest.java new file mode 100644 index 0000000..6a11129 --- /dev/null +++ b/src/test/java/edu/iu/uits/lms/multiclassmessenger/swagger/SwaggerUiCustomTest.java @@ -0,0 +1,50 @@ +package edu.iu.uits.lms.multiclassmessenger.swagger; + +/*- + * #%L + * lms-canvas-multiclassmessenger + * %% + * Copyright (C) 2015 - 2024 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import edu.iu.uits.lms.lti.swagger.AbstractSwaggerUiCustomTest; +import edu.iu.uits.lms.multiclassmessenger.WebApplication; +import edu.iu.uits.lms.multiclassmessenger.config.SecurityConfig; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest(classes = {WebApplication.class, SecurityConfig.class, SwaggerMulticlassMessengerTestConfig.class}) +public class SwaggerUiCustomTest extends AbstractSwaggerUiCustomTest { + + @Override + protected List getEmbeddedSwaggerToolPaths() { + return SwaggerTestUtil.getEmbeddedSwaggerToolPaths(super.getEmbeddedSwaggerToolPaths()); + } +}