feat: [NETWORK] mock http calls (#83)

* feat: [NETWORK] mock http calls

* feat: [NETWORK] mock http calls

* feat: [NETWORK] mock http calls

* feat: [NETWORK] mock http calls

* used buildmap

* used buildmap

* used buildmap

---------

Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
Florent CHAMPIGNY 2025-08-11 17:20:31 +02:00 committed by GitHub
parent b89c3f8a1d
commit 9d73df5e5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 334 additions and 8 deletions

View file

@ -2,7 +2,9 @@ package io.github.openflocon.flocon.plugins.network
import io.github.openflocon.flocon.core.FloconPlugin
import io.github.openflocon.flocon.plugins.network.model.FloconNetworkRequest
import io.github.openflocon.flocon.plugins.network.model.MockNetworkResponse
interface FloconNetworkPlugin : FloconPlugin {
val mocks: Collection<MockNetworkResponse>
fun log(call: FloconNetworkRequest)
}

View file

@ -5,6 +5,7 @@ data class FloconNetworkRequest(
val response: Response,
val durationMs: Double,
val floconNetworkType: String,
val isMocked: Boolean,
) {
data class Request(
val url: String,

View file

@ -0,0 +1,22 @@
package io.github.openflocon.flocon.plugins.network.model
import java.util.regex.Pattern
data class MockNetworkResponse(
val expectation: Expectation,
val response: Response,
) {
data class Expectation(
val urlPattern: String, // a regex
val pattern: Pattern,
val method: String, // can be get, post, put, ... or a wildcard *
)
data class Response(
val httpCode: Int,
val body: String,
val mediaType: String,
val delay: Long,
val headers: Map<String, String>,
)
}