Has anyone used Wiremock record/playback feature against Box?
We have integration tests that integration with Box.com api. I want to mock these so that we have option to run these tests without actually calling api.box.com.
So I am attempting to use http://wiremock.org/docs/record-playback/
1) Download wiremock standalone server 2.2.2: http://central.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.2.2/wiremock-standalone-2.2.2.jar
2) Run a wiremock server with --record-mappings enabled where you have a --proxy-all for each endpoint you are mocking.
java -jar wiremock-standalone-2.2.2.jar --proxy-all "https://api.box.com" --port 4444 --record-mappings
3) Change the endpoint of the Box SDK.
git clone ***@example.com:box/box-java-sdk.git
Replace all https://api.box.com with http://localhost:4444
When I run the Box test, it gives me an error:
{"error":"invalid_grant","error_description":"Please check the 'aud' claim."}
Full log
20**removed**:36:03.884 Verbose logging enabled 20**removed**:36:04.512 Verbose logging enabled 20**removed**:36:04.545 Recording mappings to ./mappings /$$ /$$ /$$ /$$ /$$ /$$ | $$ /$ | $$|__/ | $$$ /$$$ | $$ | $$ /$$$| $$ /$$ /$$$$$$ /$$$$$$ | $$$$ /$$$$ /$$$$$$ /$$$$$$$| $$ /$$ | $$/$$ $$ $$| $$ /$$__ $$ /$$__ $$| $$ $$/$$ $$ /$$__ $$ /$$_____/| $$ /$$/ | $$$$_ $$$$| $$| $$ \__/| $$$$$$$$| $$ $$$| $$| $$ \ $$| $$ | $$$$$$/ | $$$/ \ $$$| $$| $$ | $$_____/| $$\ $ | $$| $$ | $$| $$ | $$_ $$ | $$/ \ $$| $$| $$ | $$$$$$$| $$ \/ | $$| $$$$$$/| $$$$$$$| $$ \ $$ |__/ \__/|__/|__/ \_______/|__/ |__/ \______/ \_______/|__/ \__/ port: 4444 proxy-all: https://api.box.com preserve-host-header: false enable-browser-proxying: false record-mappings: true match-headers: [Accept, Content-Type] no-request-journal: false verbose: true 20**removed**:36:35.780 Proxying: POST https://api.box.com/oauth2/token 20**removed**:36:36.672 Request received: 127.0.0.1 - POST /oauth2/token Accept: [*/*] Connection: [keep-alive] User-Agent: [python-requests/2.10.0] Host: [localhost:4444] Accept-Encoding: [gzip, deflate] Content-Length: [822] Content-Type: [application/x-www-form-urlencoded] client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjJhdDMzamNtIn0.eyJzdWIiOiI5MzQ1MjkiLCJpc3MiOiJ5aWhqejJvd3F3bHJuNWVtbmI3dmd2a3B4bmg0YjcycSIsImp0aSI6Imt6clFPNWs0Z1dJeThqanA5T0FwTVQwRWx3IiwiZXhwIjoxNDc4MjIzNDI1LCJib3hfc3ViX3R5cGUiOiJlbnRlcnByaXNlIiwiYXVkIjoiaHR0cHM6Ly9hcGkuYm94LmNvbS9vYXV0aDIvdG9rZW4ifQ.PWAJ700Ki8g9Ixy-AG5CveL0IWHew1UowQd0UKxEThDwDB6HyQyimAulrd2SmzocuBmdTAhUT_VKmU-uRS-XNBoNBRJCJGqQvshm-N6RcjlFR5hvrdmXhxtCDiG8R-of03EgXQVDZo4EUkO8us0T94P7ed0TpeeBaEzYYwRdFUC5eHdWor_eUJmJRo6l_o9miT4xwMsIdtr5myZ1O_2Ol8WF2zK-m6Ook0A7IBMBnsxUFeHNUI1w58aY1WvNdfFeT_egetzIUqJ8oFpszRxBDUobHQXwoMKzKfocMgOnxdH5TVX04CKebH-B8lILox0zMVKf4ztELDcKth3Os5kb-g&client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&box_device_id=0 Matched response definition: { "status" : 200, "proxyBaseUrl" : "https://api.box.com" } Response: HTTP/1.1 200 Server: [ATS] Date: [Fri, 04 Nov 20**removed**:36:36 GMT] Content-Type: [application/json] Cache-Control: [no-store] Strict-Transport-Security: [max-age=31536000; includeSubDomains] Vary: [Accept-Encoding] Content-Encoding: [gzip] Set-Cookie: [box_visitor_id=581be62461cd41.75776914; expires=Sat, 04-Nov-20**removed**:36:36 GMT; Max-Age=31536000; path=/; domain=.box.com; secure, bv=OPS-41430; expires=Fri, 11-Nov-20**removed**:36:36 GMT; Max-Age=608400; path=/; domain=.app.box.com; secure, cn=16; expires=Sat, 04-Nov-20**removed**:36:36 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure] Age: [0] Transfer-Encoding: [chunked] Connection: [keep-alive] �\00\00\00\00\00\00�VJLNN-.�/��N�S�R2��,sO����q.tvIq7 �����31�+�U�QJ�(�,J-���7��0�Q�J�2�KRS��(YE��(�͋/�,H���X�Z�T\00\00\00��\00���n\00\00\00 20**removed**:36:36.675 Recording mappings for /oauth2/token 20**removed**:36:36.736 Proxying: POST https://api.box.com/oauth2/token 20**removed**:36:37.18 Request received: 127.0.0.1 - POST /oauth2/token Accept: [*/*] Connection: [keep-alive] User-Agent: [python-requests/2.10.0] Host: [localhost:4444] Accept-Encoding: [gzip, deflate] Content-Length: [867] Content-Type: [application/x-www-form-urlencoded] client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjJhdDMzamNtIn0.eyJzdWIiOiJBcHBVc2VyXzIyNDEwMl93a3FpeFlydXA1QGJveGRldmVkaXRpb24uY29tIiwiaXNzIjoieWloanoyb3dxd2xybjVlbW5iN3ZndmtweG5oNGI3MnEiLCJqdGkiOiJOdjllaXNuRlUzV2tjY1RhQXpMNEF5dW9LV3FWYSIsImV4cCI6MTQ3ODIyMzQyNiwiYm94X3N1Yl90eXBlIjoidXNlciIsImF1ZCI6Imh0dHBzOi8vYXBpLmJveC5jb20vb2F1dGgyL3Rva2VuIn0.VB9kEV2LQv6Y6o-TKtQKLP8j_55vn_jCpqOQb8Mvi66_b6qqloj0aQ5k8HfZ5fbgXXg-ispn-OoUQnbRakRunag2shOfl7dGBhDacdK7PDrZKDQac50vy99y2Xjs9XrQCyuUUPAUTe-9PihvjM5guQepuMPoOPlbWtqEexVczvicDYt6sxKYfDRu8gbYzNFV3ZiyTCYvEZEP1K_z2lCSgOG4mDxnjWqN4N3ATf_WM_FMh9q76O65q6Dir1Ny8fpkT2Z8FzFkRvNc8Nj3wEyeV6VvGK81IIIjJNGyQ2-fu75cjO7s5JDSHylwygGhHp1qWWkjxDQVhiDBiR4AFwUNNQ&client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&box_device_id=0 Matched response definition: { "status" : 200, "proxyBaseUrl" : "https://api.box.com" } Response: HTTP/1.1 200 Server: [ATS] Date: [Fri, 04 Nov 20**removed**:36:36 GMT] Content-Type: [application/json] Cache-Control: [no-store] Strict-Transport-Security: [max-age=31536000; includeSubDomains] Vary: [Accept-Encoding] Content-Encoding: [gzip] Set-Cookie: [box_visitor_id=581be624c438e9.98453309; expires=Sat, 04-Nov-20**removed**:36:36 GMT; Max-Age=31536000; path=/; domain=.box.com; secure, bv=OPS-41430; expires=Fri, 11-Nov-20**removed**:36:36 GMT; Max-Age=608400; path=/; domain=.app.box.com; secure, cn=57; expires=Sat, 04-Nov-20**removed**:36:36 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure] Age: [0] Transfer-Encoding: [chunked] Connection: [keep-alive] �\00\00\00\00\00\00�VJLNN-.�/��N�S�RJ7�,��L-)5 .+ �56��vM�r4�t�N R�QJ�(�,J-���76�4�Q�J�2�KRS��(YE��(�͋/�,H���X�Z�T\00\00\00��\001,Vjn\00\00\00 20**removed**:36:37.20 Recording mappings for /oauth2/token 20**removed**:36:37.112 Request received: 127.0.0.1 - GET /2.0/users/me Connection: [keep-alive] User-Agent: [box-python-sdk-2.0.0a2] Authorization: [Bearer g59qPY9etu5SvuRUm37ZkEezA2YCVKbR] Host: [localhost:4444] Accept-Encoding: [gzip, deflate] Accept: [*/*] Matched response definition: { "status" : 200, "bodyFileName" : "body-users-me-ms3eo.json", "headers" : { "Server" : "ATS", "Date" : "Fri, 04 Nov 20**removed**:27:58 GMT", "Content-Type" : "application/json", "Cache-Control" : "no-cache, no-store", "Strict-Transport-Security" : "max-age=31536000; includeSubDomains", "Vary" : "Accept-Encoding", "Age" : "0", "Connection" : "keep-alive" } } Response: HTTP/1.1 200 Server: [ATS] Date: [Fri, 04 Nov 20**removed**:27:58 GMT] Content-Type: [application/json] Cache-Control: [no-cache, no-store] Strict-Transport-Security: [max-age=31536000; includeSubDomains] Vary: [Accept-Encoding] Age: [0] Connection: [keep-alive] {"type":"user","id":"removed for privacy","name":"test505","login":"***@example.com","created_at":"20**removed**T10:37:**removed**:00","modified_at":"20**removed**T07:17:**removed**:00","language":"en","timezone":"America\/Los_Angeles","space_amount":removed for privacy40,"space_used":47285,"max_upload_size":removed for privacy8,"status":"active","job_title":"","phone":"","address":"","avatar_url":"https:\/\/app.box.com\/api\/avatar\/large\/removed for privacy"} 20**removed**:36:37.113 Not recording mapping for /2.0/users/me as this has already been received 20**removed**:36:37.165 Proxying: POST https://api.box.com/oauth2/token 20**removed**:36:37.305 Request received: 127.0.0.1 - POST /oauth2/token Accept-Charset: [utf-8] Accept: [text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2] User-Agent: [Box Java SDK v2.1.1] Connection: [keep-alive] Host: [localhost:4444] Accept-Encoding: [gzip] Content-Length: [920] Content-Type: [application/x-www-form-urlencoded] grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&assertion=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjJhdDMzamNtIn0.eyJpc3MiOiJ5aWhqejJvd3F3bHJuNWVtbmI3dmd2a3B4bmg0YjcycSIsImF1ZCI6Imh0dHA6Ly9sb2NhbGhvc3Q6NDQ0NC9vYXV0aDIvdG9rZW4iLCJleHAiOjE0NzgyMjM0NTcsInN1YiI6IkFwcFVzZXJfMjI0MTAyX3drcWl4WXJ1cDVAYm94ZGV2ZWRpdGlvbi5jb20iLCJib3hfc3ViX3R5cGUiOiJ1c2VyIiwianRpIjoiY0lqdzRYR0IzYUlVdFVIbnVHRkUwcGRqQTd1RjV2Y2d3a2UtUnNnNEZfZ1BMS1VMTUpqTmZsaG5VZ2FPQVV6dEYzRHF6dlRDck1hMXZNdU5GbzhBWUEifQ.gZSjD8kE9nzakDmQiEiAZLFTw0z3mtk7_stq39IK4jzgT-GeQL6zx3vGxiN2AUV54lQ9ACL2cOZowJiXB20CN1ZL9A2jclD5o8quDxUSvxmWODWOgUs8UTPE7Kav1mhkW-VrxNkdbWFoSI7_3KdCLjm4WutmnCNKlbFcVPUbsKlZsYfSatAfTye4rgSoJZqcNAQyIVTBMe2Bxk4C2R8Xrs8mBSp9EZRyxa2FZx5WJaOVIpFnLr98sDPbgJ7Ta3hBB9ASIdA5lsf9fpWWYsc5K3xi8PwPxVU9sMruBIzOGnFWRG5_DBCCt6vTGbc37GlE6g-E_8ZnEt7WKbyEIcwsXw Matched response definition: { "status" : 200, "proxyBaseUrl" : "https://api.box.com" } Response: HTTP/1.1 400 Server: [ATS] Date: [Fri, 04 Nov 20**removed**:36:37 GMT] Content-Type: [application/json] Content-Length: [77] Cache-Control: [no-store] Strict-Transport-Security: [max-age=31536000; includeSubDomains] Set-Cookie: [box_visitor_id=581be62537b842.39909194; expires=Sat, 04-Nov-20**removed**:36:37 GMT; Max-Age=31536000; path=/; domain=.box.com; secure, bv=OPS-41430; expires=Fri, 11-Nov-20**removed**:36:37 GMT; Max-Age=608400; path=/; domain=.app.box.com; secure, cn=45; expires=Sat, 04-Nov-20**removed**:36:37 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure] Age: [0] Connection: [keep-alive] {"error":"invalid_grant","error_description":"Please check the 'aud' claim."}
If this isn't going to work, is there any way to mock Box? Like a docker image or something? Any help is appreciated.
Please sign in to leave a comment.
Comments
0 comments