Skip to content

Commit

Permalink
GH-2197 Update base path test playground
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Aug 19, 2024
1 parent b8596c9 commit 9ac2182
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("FunctionName")

package com.reposilite.web

import com.reposilite.RecommendedLocalSpecificationJunitExtension
Expand Down Expand Up @@ -65,13 +67,18 @@ internal class BasePathIntegrationTest : ReposiliteSpecification() {
.delete("$basePath/<uri>") { Unirest.delete(it.reposiliteLocation()).redirect(it) }
.options("$basePath/<uri>") { Unirest.options(it.reposiliteLocation()).redirect(it) }
.get("/stop") { await.countDown() }
.start(80)
.start(8080)

await.await()
}

private val restrictedHttpHeaders = listOf(
"Connection",
"Host",
)

private fun <R : HttpRequest<*>> R.redirect(ctx: Context) {
ctx.headerMap().forEach { (key, value) -> header(key, value) }
ctx.headerMap().filter { it.key !in restrictedHttpHeaders }.forEach { (key, value) -> header(key, value) }
val response = this.asBytes()
response.headers.all().forEach { ctx.header(it.name, it.value) }
ctx.status(response.status).result(response.body)
Expand Down

0 comments on commit 9ac2182

Please sign in to comment.