-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent swagger-config from being loaded twice in case of no groups. F…
- Loading branch information
bnasslahsen
committed
Jun 7, 2020
1 parent
2f7c4c6
commit 46dff5b
Showing
6 changed files
with
231 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...penapi-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocRedirectQueryParams1Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* | ||
* * Copyright 2019-2020 the original author or authors. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.ui.app1; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import test.org.springdoc.ui.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.web.servlet.MvcResult; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@TestPropertySource(properties = "springdoc.swagger-ui.display-query-params-without-oauth2=true") | ||
public class SpringDocRedirectQueryParams1Test extends AbstractSpringDocTest { | ||
|
||
@Test | ||
public void shouldRedirectWithQueryParamsWithoutOauth2() throws Exception { | ||
MvcResult mvcResult = mockMvc.perform(get("/swagger-ui.html")) | ||
.andExpect(status().isFound()).andReturn(); | ||
|
||
String locationHeader = mvcResult.getResponse().getHeader("Location"); | ||
assertEquals("/swagger-ui/index.html?url=/v3/api-docs", locationHeader); | ||
} | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...penapi-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocRedirectQueryParams2Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* | ||
* * Copyright 2019-2020 the original author or authors. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.ui.app1; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import test.org.springdoc.ui.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.web.servlet.MvcResult; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@TestPropertySource(properties = "springdoc.swagger-ui.display-query-params=true") | ||
public class SpringDocRedirectQueryParams2Test extends AbstractSpringDocTest { | ||
|
||
@Test | ||
public void shouldRedirectWithQueryParams() throws Exception { | ||
MvcResult mvcResult = mockMvc.perform(get("/swagger-ui.html")) | ||
.andExpect(status().isFound()).andReturn(); | ||
|
||
String locationHeader = mvcResult.getResponse().getHeader("Location"); | ||
assertEquals("/swagger-ui/index.html?oauth2RedirectUrl=http://localhost/swagger-ui/oauth2-redirect.html&url=/v3/api-docs", locationHeader); | ||
} | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...ux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectQueryParams1Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* | ||
* * Copyright 2019-2020 the original author or authors. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.ui.app1; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import test.org.springdoc.ui.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
|
||
@TestPropertySource(properties = "springdoc.swagger-ui.display-query-params-without-oauth2=true") | ||
public class SpringDocApp1RedirectQueryParams1Test extends AbstractSpringDocTest { | ||
|
||
@Test | ||
public void shouldRedirectWithQueryParamsWithoutOauth2() throws Exception { | ||
|
||
WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/swagger-ui.html").exchange() | ||
.expectStatus().isTemporaryRedirect(); | ||
responseSpec.expectHeader() | ||
.value("Location", Matchers.is("/webjars/swagger-ui/index.html?url=/v3/api-docs")); | ||
|
||
} | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...ux-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocApp1RedirectQueryParams2Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* | ||
* * Copyright 2019-2020 the original author or authors. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.ui.app1; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import test.org.springdoc.ui.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
|
||
@TestPropertySource(properties = "springdoc.swagger-ui.display-query-params=true") | ||
public class SpringDocApp1RedirectQueryParams2Test extends AbstractSpringDocTest { | ||
|
||
@Test | ||
public void shouldRedirectWithQueryParams() throws Exception { | ||
|
||
WebTestClient.ResponseSpec responseSpec = webTestClient.get().uri("/swagger-ui.html").exchange() | ||
.expectStatus().isTemporaryRedirect(); | ||
responseSpec.expectHeader() | ||
.value("Location", Matchers.is("/webjars/swagger-ui/index.html?oauth2RedirectUrl=/webjars/swagger-ui/oauth2-redirect.html&url=/v3/api-docs")); | ||
|
||
} | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |