move "Check auth on all routes" extension into the class
This commit is contained in:
@@ -84,9 +84,8 @@ class `Check auth on all routes` : BaseTest() {
|
|||||||
return """HttpStatus ${statusCode.value} for: ${method.value.padStart(6, ' ')} $uri"""
|
return """HttpStatus ${statusCode.value} for: ${method.value.padStart(6, ' ')} $uri"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun Path.buildUrl(path: String, methodName: String, context: OAIContext): String {
|
private fun Path.buildUrl(path: String, methodName: String, context: OAIContext): String {
|
||||||
val urlReplaced = this.getParametersIn(context, "path")
|
val urlReplaced = this.getParametersIn(context, "path")
|
||||||
.fold(path) { pathToReplace: String, parameter: Parameter ->
|
.fold(path) { pathToReplace: String, parameter: Parameter ->
|
||||||
"""\{${parameter.name}}""".toRegex().replace(
|
"""\{${parameter.name}}""".toRegex().replace(
|
||||||
@@ -121,9 +120,9 @@ private fun Path.buildUrl(path: String, methodName: String, context: OAIContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "$urlReplaced$allParameters"
|
return "$urlReplaced$allParameters"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Parameter.generateFakeValue(): String {
|
private fun Parameter.generateFakeValue(): String {
|
||||||
return if (example != null) {
|
return if (example != null) {
|
||||||
example.toString()
|
example.toString()
|
||||||
} else if (schema.type == "string" && schema.format == "uuid") {
|
} else if (schema.type == "string" && schema.format == "uuid") {
|
||||||
@@ -131,9 +130,9 @@ private fun Parameter.generateFakeValue(): String {
|
|||||||
} else {
|
} else {
|
||||||
"example123"
|
"example123"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Parameter.generateFakeArray(): List<String> {
|
private fun Parameter.generateFakeArray(): List<String> {
|
||||||
if (schema.type != "array") {
|
if (schema.type != "array") {
|
||||||
error("Parameter is not an array")
|
error("Parameter is not an array")
|
||||||
}
|
}
|
||||||
@@ -144,4 +143,6 @@ private fun Parameter.generateFakeArray(): List<String> {
|
|||||||
} else {
|
} else {
|
||||||
listOf("example123")
|
listOf("example123")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user