iridakos / duckrails Goto Github PK
View Code? Open in Web Editor NEWDevelopment tool to mock API endpoints quickly and easily (docker image available)
Home Page: https://github.com/iridakos/duckrails/wiki
License: MIT License
Development tool to mock API endpoints quickly and easily (docker image available)
Home Page: https://github.com/iridakos/duckrails/wiki
License: MIT License
Is possible connect db postgres: aws, gcp or other?
Im try below:
environment:
DATABASE_ADAPTER: postgresql
DATABASE_PORT: 5432
DATABASE_NAME: postgres
DATABASE_USERNAME: postgres
DATABASE_HOSTNAME: "bd-mock-1.testeteste.us-east-1.rds.amazonaws.com"
DATABASE_PASSWORD: passwd
log duck:
https://gist.github.com/renatovieiradesouza/6cf37210535cafb3f658d52bd9dc31f9
i install duckrails by docker. How can i export mocks data?
Hello,wiki dosen't has "Advanced mock configuration" JavaScript sample. Could you give me a example?
Whenever you do a sleep or proxy data from another service, all mocks and the UI wait for the current operation to finish.
That would help easy sharing of common mocks.
User should be allowed to define overlapping routes, for example:
/posts/123
/posts/:post_id
The ordering will allow to set the first one to be matched before the second one.
i've setup the application and so far it seems to be working, however the styling is definitely off. parts of the page, particularly the header and footer look like the css is mostly missing. my first guess is that it has to do with differences in the foundation-rails gem. what gem version works for you guys?
This looks really cool. Can you make a docker image out of it so I don't have to clone the repo?
Hello,
I often dupplicate manually many endpoints containing long headers. Which takes very long to copy past to a new one.
It would be great to have a button in a "mock", allowing to "dupplicate a mock".
A modal would show asking which name we want to save the mock as.
Thanks !
When evaluating Javascript code, provide the headers as a hash.
At the moment the headers are provided as array of two-element arrays making it hard to be accessed in the script.
Current state
[["Content-Type", "text/html"], ["header-name", "header-value"]]
Desired state
{
"Content-Type": "text/html",
"header-name": "header-value"
}
Create a new page for list all call on Duckrails for list all call at mock.
If I've a lot of mock, it might be nice to be able to prepend the route of all my mocks by something (e.g add /api/v1
to some mock).
I'd love to have a view with all my mocks and drag them to build my desired path.
It might also be interesting to use this feature to create a "common" configuration (e.g. common headers)
If you'd like this feature, I'm happy to propose an implementation.
Cheers :)
DuckRails 2.1.9
Running on Docker
I was just playing around, and wanted to dynamically change responses headers. When I tried returning a JSON object with a headers
key I get a 500: "We're sorry, but something went wrong".
To validate that I was writing the JS correctly, I just grabbed your example code for the response body, added the headers key and returned it.
Here is the code
var date = new Date();
date.setDate(date.getDate() - Math.floor(Math.random() * 30 + 1) );
var obj = {
"headers":{
"current_page": Math.floor((Math.random() * 456) + 1),
"started_reading": date.toDateString()
}
}
return JSON.stringify(obj);
Expected: Headers would now have a current_page
and started_reading
key in my curl.
Actual: Return code 500, HTML with
<div class="dialog">
<div>
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
The docker iridakos/duckrails
images ships with a static SECRET_KEY_BASE
key. This is a security risk, the key should be supplied by user from an ENV when the user runs the container.
(PR brewing to fix)
Where do I find this log that the message says.
Is possible verification in advanced mode:
Not work for me:
var status_code =500;
if (parameters['idOrigem'] == 64){
var status_code = 200;
return JSON.stringify(status_code);
} else if (parameters['idOrigem'] == "164") {
var status_code = 400;
return JSON.stringify(status_code);
} else {
return JSON.stringify(status_code);
}
If I'm on the second page of results (e.g. mocks?page=10
) and I click the to activate a mock, I am redirect without the page
parameter thereby losing what page I'm on.
Add flag to Mock model and don't register the route if it's deactivated.
After bundle install
and rake db:setup
, when I run my rails server, the layout is broken (missing). I get errors such as this one:
Started GET "/javascripts/vendor/modernizr.js" for ::1 at 2016-03-19 08:41:12 +0100
ActionController::RoutingError ((╯°□°)╯︵ ┻━┻ : No route matches [GET] "/javascripts/vendor/modernizr.js"):
Tool looks really useful and looking forward to use it!
Dealing with CVE-2018-8048 - Loofah XSS Vulnerability
Does the app stores incoming requests? If so where does it store them?
Hello,
I'm trying to retrieve a value from a request header for using at body content section for my response. The request header the client sends looks like it:
Authorization: 123#abc
Then, at body content section at DuckRails, I tried to read that value this way:
var header = headers['Authorization'].split('#')[1];
But when I test the response I get a 200 Ok, but with this error:
Duckrails-Error: TypeError: Cannot read property 'split' of undefined
Am I reading the headers in a wrong way?
i see wiki "Creating a dynamic mock that wraps an existing API call".
But wiki just has ruby sample.I want to do it in JavaScript.Please add an JavaScript Sample
Reported by Github:
rails-html-sanitizer ~> 1.0.4
Hi,
When developing, I'm using Duckrails to mock my API. Sometimes I'd like the same endpoint to respond with a different body (and/or a different status code).
Do you think this could make sense to add this feature?
It can wether be with a "special" query (e.g. ?duckrails_body_name=no_user
) or on the web interface?
I'm happy to provide a PR if you are happy with this.
Hi,
could you please add support for importing/exporting RAML (http://raml.org)?
Is there currently a way to use optional query parameters for an endpoint?
For example, I would like to be able to use
localhost/v1/route?optional=1&dynamic=1
and still be able to hit localhost/v1/route
without the query parameters...
When I attempt to add a query parameter to a mock endpoint then it is automatically "required", or else the endpoint is no longer found when trying to hit it.
Is possible run request http with javascript into responseBody the of mock? I need to import other lib for decrypt content responseBody.
i want to require some *.js file, how can i do.
i've try require('*.js')
, but return empty page. i think there is some error with require
method
Provide a mock show page that will allow users to view a mock configuration with a legit layout.
Puma caught this error: SQLite3::SQLException: no such table: application_state: SELECT "application_state".* FROM "application_state" ORDER BY "application_state"."id" DESC LIMIT 1 (ActiveRecord::StatementInvalid)
/var/lib/gems/2.5.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in `initialize'
/var/lib/gems/2.5.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in `new'
/var/lib/gems/2.5.0/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in `prepare'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:284:in `block in exec_query'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/var/lib/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:281:in `exec_query'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/database_statements.rb:356:in `select'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/querying.rb:39:in `find_by_sql'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/relation.rb:639:in `exec_queries'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/relation.rb:515:in `load'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/relation.rb:243:in `to_a'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/relation/finder_methods.rb:500:in `find_nth_with_limit'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/relation/finder_methods.rb:484:in `find_nth'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/relation/finder_methods.rb:127:in `first'
/var/lib/gems/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/querying.rb:3:in `first'
/home/watcher/duckrails/app/models/duckrails/application_state.rb:24:in `instance'
/home/watcher/duckrails/lib/duckrails/synchronizer.rb:10:in `call'
/var/lib/gems/2.5.0/gems/railties-4.2.11.1/lib/rails/rack/logger.rb:38:in `call_app'
/var/lib/gems/2.5.0/gems/railties-4.2.11.1/lib/rails/rack/logger.rb:20:in `block in call'
/var/lib/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
/var/lib/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/tagged_logging.rb:26:in `tagged'
/var/lib/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/tagged_logging.rb:68:in `tagged'
/var/lib/gems/2.5.0/gems/railties-4.2.11.1/lib/rails/rack/logger.rb:20:in `call'
/var/lib/gems/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
/var/lib/gems/2.5.0/gems/actionpack-4.2.11.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
/var/lib/gems/2.5.0/gems/rack-1.6.11/lib/rack/methodoverride.rb:22:in `call'
/var/lib/gems/2.5.0/gems/rack-1.6.11/lib/rack/runtime.rb:18:in `call'
/var/lib/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/var/lib/gems/2.5.0/gems/rack-1.6.11/lib/rack/lock.rb:17:in `call'
/var/lib/gems/2.5.0/gems/actionpack-4.2.11.1/lib/action_dispatch/middleware/static.rb:120:in `call'
/var/lib/gems/2.5.0/gems/rack-1.6.11/lib/rack/sendfile.rb:113:in `call'
/var/lib/gems/2.5.0/gems/railties-4.2.11.1/lib/rails/engine.rb:518:in `call'
/var/lib/gems/2.5.0/gems/railties-4.2.11.1/lib/rails/application.rb:165:in `call'
/var/lib/gems/2.5.0/gems/rack-1.6.11/lib/rack/content_length.rb:15:in `call'
/var/lib/gems/2.5.0/gems/puma-3.12.0/lib/puma/configuration.rb:225:in `call'
/var/lib/gems/2.5.0/gems/puma-3.12.0/lib/puma/server.rb:658:in `handle_request'
/var/lib/gems/2.5.0/gems/puma-3.12.0/lib/puma/server.rb:472:in `process_client'
/var/lib/gems/2.5.0/gems/puma-3.12.0/lib/puma/server.rb:332:in `block in run'
/var/lib/gems/2.5.0/gems/puma-3.12.0/lib/puma/thread_pool.rb:133:in `block in spawn_thread'
headless Debian10 x64
Hi guys,
I'm wondering, if there is any way to log body of incomming requests?
Thank you in advance.
It would be nice to have something like python script as available body type.
I was thinking of creating a template python script which would read from the stdin
and then execute(evaluate?) the input.
Then, via ruby, we could start a process (using the childprocess
gem) like python lib/python/template.py
and send the mock's body to the process' stdin
.
Hi, this is a cool tool, but a little outside what I was hoping to use it for.
I'm building an XML API which is going to spend most of it's time receiving data rather than serving it - as such, the most important bit is the format in which the data is received - that is, does it match what I'll be expecting?
If something which allows for this type of validation could be added, that would make my life much easier.
Thank you.
How to change status code in return? I have 3 mock and need only one, more with status code different.
Im Try:
var ob = {"status_code": 500};
JSON.stringify(ob);
In Ruby ok:
<%=
{status_code: 500}.to_json
%>
Can the embedded code under advance customization read post data?
dummy-json is a useful template engine that lets you create dummy json data very easily
docker run --name=example_iridakos.duckrails.release-v2.1.5 -v=/Users/krystian.panek/Projects/gradle-aem-multi/duckrails:/opt/duckrails/db -p=8080:80 --rm iridakos/duckrails:release-v2.1.5
WARNING: Environment variable SECRET_KEY_BASE has not been set - Setting a random SECRET_KEY_BASE
rake aborted!
ActiveRecord::StatementInvalid: Could not find table 'mocks'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/sqlite3_adapter.rb:501:in `table_structure'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/sqlite3_adapter.rb:375:in `columns'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/attributes.rb:93:in `columns'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/attributes.rb:98:in `columns_hash'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:48:in `columns_hash'
but when I use just duckrails
on the left side of volume it works.
docker run --name=example_iridakos.duckrails.release-v2.1.5 -v=duckrails:/opt/duckrails/db -p=8080:80 --rm iridakos/duckrails:release-v2.1.5
still when using absolute path or relative path, in both cases seems that volume is working / file duckrails/production.sqlite3
is created... so that seems that is is something wrong later on DuckRails runtime side.
this is blocking me in case of using Duckrails on Windows on which I need to support Docker Toolbox in which absolute volume paths usage is essential.
it would be nice to have it fixed :)
greetings, Krystian
Hi Friends, i run Duckrails with docker, more i get error below:
mesg: ttyname failed: Inappropriate ioctl for device
Command executed:
docker run -p 8080:80 -v /Users/renato/duck:/opt/duckrails/db iridakos/duckrails:release-v2.1.0
The output the command above: https://gist.github.com/renasti/09046677fc35a45f4ace54be250a356f
Im using Mac OS X
Hello,
this is my first work with any mock server.
I am sending from client(via method POST) to duckrails json data.
Is possible pass the values from the clients request into response a return them back to the client?
Thank You
Hi, I am following the github example. After creating a new mock and save the route, when I go to /posts on cloud9 or http://localhost:3000/posts on my local machine I get this error: No route matches [GET] "/posts"
. Is there something I am missing?
User should be able to define how many mocks wants to view per page.
I'm using an AWS instance of medium type (4gb ram and 2 vcpu), but when the mock is accessed by some cell phones, it is inoperative and sometimes after a few minutes it returns. Anybody can say me tell me something related to this? What is the ideal machine? Is there a different configuration to use?
How to configure fot accept parameter empty? My ideia is return default value in case
I need create a mock example: /user/v1/user-credential
with params:
document = 123
with return:
{
"document" : "123"
}
But, i need create same mock name /user/v1/user-credential with return alternative, example:
with params
document = 092
with return
{
"document" : "092",
"name" : "Renato"
}
How to make this? I look the documentation, but not found solution.
Like JS.
The route Synchronizer is not threadsafe and fails to consistently reload routes across threads.
Test case:
ab -c 20 -n 200000 http://URL-FOR-MOCK-A
Expected:
Routes reload as expected.
Observed:
Routes do not load consistently across some app threads and app throws errors due to missing routes.
(PR brewing)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.