Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arildojr7/iris-mock
A kotlin tool to intercept android network calls, modify requests/responses and mock entire APIs. Also includes a cool DSL, that helps to reduce boilerplate code and simplify development.
https://github.com/arildojr7/iris-mock
android interceptor mock network okhttp3
Last synced: about 2 months ago
JSON representation
A kotlin tool to intercept android network calls, modify requests/responses and mock entire APIs. Also includes a cool DSL, that helps to reduce boilerplate code and simplify development.
- Host: GitHub
- URL: https://github.com/arildojr7/iris-mock
- Owner: arildojr7
- License: apache-2.0
- Created: 2023-04-30T13:31:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-31T06:14:22.000Z (5 months ago)
- Last Synced: 2024-08-01T00:25:03.865Z (5 months ago)
- Topics: android, interceptor, mock, network, okhttp3
- Language: Kotlin
- Homepage: https://irismock.arildo.dev/
- Size: 1010 KB
- Stars: 61
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing/contributing.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
- awesome-list - arildojr7/iris-mock - A kotlin tool to intercept android network calls, modify requests/responses and mock entire APIs. Also includes a cool DSL, that helps to reduce boilerplate code and simplify development. (Kotlin)
README
A kotlin tool to intercept android network calls, modify requests/responses and mock entire APIs. Also includes a cool DSL, that helps to reduce boilerplate code and simplify development.
btw, Iris is my daughter's name 🥰## Features
- Works with Retrofit, Volley and every libs that depend on OkHttp
- Allow intercept call on 3rd-party libs
- [DSL](https://kotlinlang.org/docs/type-safe-builders.html) to avoid boilerplate## Why use iris mock?
- A centralized tool to log, intercept and modify requests/response
- As it works at bytecode level, can be used with 3rd-party libs
- No need to apply KAPT or KSP, since it's implemented directly through KCP
- No need to do SSL things, like inject certificate## How to use
#### build.gradle.kts
```kotlin
plugins {
id("dev.arildo.iris-mock-plugin") version "1.1.0"
}
```Using legacy plugin application - older gradle
```kotlin
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("dev.arildo:iris-mock-plugin:1.1.0-alpha04")
}
}apply(plugin = "dev.arildo.iris-mock-plugin")
```#### Code
Just create a class implementing the `Interceptor` interface and annotate it with `@IrisMockInterceptor`. That's all. The interceptor will be automatically injected at `OkHttp````kotlin
@IrisMockInterceptor
class MyInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain) = irisMock(chain) {
enableLogs() // you can log requestsonGet(contains = "user/profile") mockResponse userProfileJson
onPost(endsWith = "/login") {
delay(2_000)
if (containsInRequestBody("validPassword")) mockResponse(successLoginJson)
else mockResponse(errorPasswordJson)
}
}
}
```See [official docs](https://irismock.arildo.dev/getting-started/configure-gradle/) for further details
## Roadmap
- Add support to [Ktor](https://github.com/ktorio/ktor)
- Expand DSL
- and many other cool things## Getting started video
[![Iris Mock](https://github.com/arildojr7/iris-mock/assets/32650006/a8526d9a-923f-49b1-b58f-fe0dbd15d051)](https://www.youtube.com/watch?v=fe3bJ55tIck)## Contributing
Feel free to open PRs and submit feature suggestions via the repository issues. Everything's welcome 😎## Support
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://bmc.link/arildojr7)## License
```
Copyright 2023 Arildo Borges JuniorLicensed 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 athttp://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.
```