Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend HTTP Client request creation for more Admin API endpoints #61

Open
picimako opened this issue Jun 20, 2023 · 0 comments
Open

Extend HTTP Client request creation for more Admin API endpoints #61

picimako opened this issue Jun 20, 2023 · 0 comments
Labels
enhancement Improvement on an existing feature feature New functionality

Comments

@picimako
Copy link
Owner

picimako commented Jun 20, 2023

Summary

WireMocha 1.0.12 introduced a new gutter icon with which HTTP Client requests can be generated from Java method calls. That feature is limited to endpoints that don't require complex requests.

Tasks

  • Introduce gutter icons for more endpoints.
  • Generate path and query parameters, as well as JSON request bodies from Java code. This will probably require two things:
    • A standardized way of converting Java based stubbing to JSON.
    • A way to handle live template generation besides the current "static" live templates used.

Candidates

Stubbing

stubFor(get(urlEqualTo("/some/thing"))

POST http://<host>:<port>/__admin/mappings
{
  "request": {
    "method": "GET",
    "url": "/some/thing"
  },
  "response": {
    ...
  }
}

WireMock.saveAllMappings() //with empty body
POST http://<host>:<port>/__admin/mappings/save

wireMockServer.editStub(get(urlEqualTo("/edit-this"))

PUT http://<host>:<port>/__admin/mappings/{id}
{
  "request": {
  "urlPath": "/edit-this",
  "method": "ANY"
  },
  "response": {
  "status": 200
  }
}

WireMock.reset() //empty body
POST http://<host>:<port>/__admin/reset
DELETE http://<host>:<port>/__admin/mappings

WireMock.importStubs(stubImport()...)

POST http://<host>:<port>/__admin/mappings/import
{
  "mappings": [
    {
    }
  ]
}

Verification

WireMock.verify(postRequestedFor(urlEqualTo("/verify/this")))

POST http://<host>:<port>/__admin/requests/count
{
  "method": "POST",
  "url": "/verify/this"
}

WireMock.getAllServeEvents(ServeEventQuery.ALL_UNMATCHED)
GET http://localhost:8080/__admin/requests?unmatched=true

WireMock.getAllServeEvents(ServeEventQuery.forStubMapping(myStubId))
GET http://localhost:8080/__admin/requests?matchingStub=59651373-6deb-4707-847c-9e8caf63266e

???
GET http://localhost:8080/__admin/requests?since=2016-06-06T12:00:00&limit=3

WireMock.findAll(putRequestedFor(urlMatching("/api/.*")))

POST http://<host>:<port>/__admin/requests/find
{
  "method": "PUT",
  "urlPattern": "/api/.*"
}

removeServeEvents(putRequestedFor(urlMatching("/api/.*").withHeader("X-Trace-Id", equalTo("123"))));

POST http://<host>:<port>/__admin/requests/remove
{
  "method": "PUT",
  "urlPattern": "/api/.*",
  "headers": {
    "X-Trace-Id": {
      "equalTo": "123"
    }
  }
}

WireMock.removeEventsByStubMetadata(matchingJsonPath("$.tags[0]", equalTo("test-57")));

POST /__admin/requests/remove-by-metadata
{
  "matchesJsonPath" : {
    "expression" : "$.tags[0]",
    "equalTo" : "test-57"
  }
}

WireMock.findNearMissesFor(myLoggedRequest)

POST http://<host>:<port>/__admin/near-misses/request
{
  "url": "/actual",
  "absoluteUrl": "http://localhost:8080/actual",
  "method": "GET",
  "clientIp": "0:0:0:0:0:0:0:1",
  "headers": {
    "User-Agent": "curl/7.30.0",
    "Accept": "*/*",
    "Host": "localhost:8080"
  },
  "cookies": {},
  "browserProxyRequest": false,
  "loggedDate": 1467402464520,
  "bodyAsBase64": "",
  "body": "",
  "loggedDateString": "2016-07-01T19:47:44Z"
}

WireMock.findNearMissesFor(getRequestedFor(urlEqualTo("/thing-url")));

POST http://<host>:<port>/__admin/near-misses/request-pattern
{
  "method": "GET"
  "url": "/thing-url",
}

Record and playback

startRecording(recordSpec())
???

@picimako picimako added enhancement Improvement on an existing feature feature New functionality labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement on an existing feature feature New functionality
Projects
None yet
Development

No branches or pull requests

1 participant