msjit / testcasedb

TestCaseDB - Web based test case management
MIT License
40 stars 18 forks source link

404 page while accessing the webapi using json format #64

Closed kiranfractal closed 9 years ago

kiranfractal commented 9 years ago

Hi,

I am trying to check the webapi with json as below and it is giving me 404 error.

cat command.json :

{ "api_request": { "command": "CheckVersion", "option1": "dummy1", "value": "1.2.3", "api_key": "oMPIgICN9KXsDhGgxfh" } }

curl -k --data-ascii @command.json https://178.79.180.79/versions /search.json?api_key=oMPIgICN9KXsDhGgxfh


<!DOCTYPE html>

TestCaseDB - (404)

The page you requested cannot be found.

kiranfractal commented 9 years ago

Any documentation on how to access new webapi's to create automation ?

Is the current API v2 is same as API v1?

kiranfractal commented 9 years ago

production.log details:

Processing by Webapiv2Controller#run as JSON Parameters: {"{ \"api_request\": { \"command\": \"CheckVersion\", \"option1\": \"dummy1\", \"value\": \"1.2.3\" }}"=>nil, "api_key"=>"oMPIgICN9KXsDhGgxfh", "object"=>"versions", "endpoint"=>"search"} WARNING: Can't verify CSRF token authenticity Completed 400 Bad Request in 4.8ms (Views: 0.3ms | ActiveRecord: 1.1ms) Processing by Webapiv2Controller#run as JSON Parameters: {"{ \"api_request\": { \"command\": \"CheckVersion\", \"option1\": \"dummy1\", \"value\": \"1.2.3\", \"api_key\": \"oMPIgICN9KXsDhGgxfh\" }}"=>nil, "object"=>"versions", "endpoint"=>"search"} WARNING: Can't verify CSRF token authenticity Completed 400 Bad Request in 1.6ms (Views: 0.3ms | ActiveRecord: 0.0ms) Processing by WebapiController#run as XML Parameters: {"<?xml version"=>"\"1.0\"?>CheckVersiondummy11.2.3", "api_key"=>"oMPIgICN9KXsDhGgxfh"} WARNING: Can't verify CSRF token authenticity Rendered webapi/run.xml.erb (0.4ms) Completed 200 OK in 12.3ms (Views: 1.6ms | ActiveRecord: 1.7ms) Processing by Webapiv2Controller#run as JSON Parameters: {"<?xml version"=>"\"1.0\"?>CheckVersiondummy11.2.3", "api_key"=>"oMPIgICN9KXsDhGgxfh", "object"=>"dummy1", "endpoint"=>"search"} WARNING: Can't verify CSRF token authenticity Completed 400 Bad Request in 5.7ms (Views: 0.2ms | ActiveRecord: 1.3ms) Processing by Webapiv2Controller#run as JSON Parameters: {"{ 'CheckVersion':{ 'dummy1':'1.2.3' }}"=>nil, "api_key"=>"oMPIgICN9KXsDhGgxfh", "object"=>"dummy1", "endpoint"=>"search"} WARNING: Can't verify CSRF token authenticity Completed 400 Bad Request in 7.5ms (Views: 0.2ms | ActiveRecord: 3.2ms) Processing by WebapiController#run as XML Parameters: {"<?xml version"=>"\"1.0\"?>CheckVersiondummy11.2.3", "api_key"=>"oMPIgICN9KXsDhGgxfh"} WARNING: Can't verify CSRF token authenticity Rendered webapi/run.xml.erb (0.1ms) Completed 200 OK in 9.2ms (Views: 0.7ms | ActiveRecord: 2.0ms) Processing by WebapiController#run as XML Parameters: {"<?xml version"=>"\"1.0\"?>CheckVersiondummy11.2.3", "api_key"=>"oMPIgICN9KXsDhGgxfh"} WARNING: Can't verify CSRF token authenticity Rendered webapi/run.xml.erb (0.1ms) Completed 200 OK in 7.8ms (Views: 0.7ms | ActiveRecord: 1.9ms)

unicorn.stdout.log details:

Started POST "/versions/search.json?api_key=oMPIgICN9KXsDhGgxfh" for 127.0.0.1 at 2014-12-29 10:53:35 +0000

ActionController::RoutingError (No route matches [POST] "/versions/search.json"): vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/show_exceptions.rb:56:incall' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/rack/logger.rb:32:in call_app' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/rack/logger.rb:18:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/request_id.rb:22:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:incall' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/runtime.rb:17:in call' vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/cache/strategy/local_cache.rb:72:incall' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/lock.rb:15:in call' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:inforward' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in pass' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:ininvalidate' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in call!' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:incall' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:484:in call' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:231:incall' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in method_missing' vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:inprocess_client' vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in worker_loop' vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:inspawn_missing_workers' vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in start' vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn_rails:209:in<top (required)>' vendor/bundle/ruby/2.0.0/bin/unicorn_rails:23:in load' vendor/bundle/ruby/2.0.0/bin/unicorn_rails:23:in

'

agramian commented 9 years ago

@kiranfractal for the v2 api the api_key is provided via the json post data not in the url. In your example you have provided the api_key both in the json data and the url unnecessarily.

There is no documentation for the v2 api yet. I opened issue #55 to address documentation more generally and once it is collectively decided how to proceed I will document the new web api.

In the meantime you can look at the unit tests for examples of v2 api usage https://github.com/msjit/testcasedb/tree/master/spec/webapi

kiranfractal commented 9 years ago

@agramian thanks a lot for the clarification. I would like to use v2 api for automation and I have documentation of using v1 for automation. Please have a look at the below documentation which uses v1 api. http://news.testcasedb.com/wp-content/uploads/2012/05/automation_example1.pdf

I am looking for a sample automation script of using v2 api.

It would be great if you let me know how to use v2 api so that I can try using them for automation rather waiting for complete documentation.

kiranfractal commented 9 years ago

How to run unit tests ? Is the below command is right ? Where will be the results stored ?

bundle exec rake spec

agramian commented 9 years ago

Run "bundle exec rspec” from the root testcasedb directory. The results are printed to the console output not stored.

kiranfractal commented 9 years ago

I am getting rspec not found error as shown below.

$ bundle exec rspec bundler: command not found: rspec Install missing gem executables with bundle install

On Tue, Dec 30, 2014 at 11:14 PM, Abtin Gramian notifications@github.com wrote:

Run "bundle exec rspec” from the root testcasedb directory. The results are printed to the console output not stored.

— Reply to this email directly or view it on GitHub https://github.com/msjit/testcasedb/issues/64#issuecomment-68378196.

kiranfractal commented 9 years ago

gem 'rspec-rails', '~> 3.0.0' is under test and development group.

I am running the app under production mode.

So it is not installed in my machine.

On Wed, Dec 31, 2014 at 10:29 AM, Kiran Patil kiran@fractalio.com wrote:

I am getting rspec not found error as shown below.

$ bundle exec rspec bundler: command not found: rspec Install missing gem executables with bundle install

On Tue, Dec 30, 2014 at 11:14 PM, Abtin Gramian notifications@github.com wrote:

Run "bundle exec rspec” from the root testcasedb directory. The results are printed to the console output not stored.

— Reply to this email directly or view it on GitHub https://github.com/msjit/testcasedb/issues/64#issuecomment-68378196.

agramian commented 9 years ago

This is intended behavior. You do not want the test only items available in the production environment.

You need to start the rails server in development or test mode and make sure the test/development environment and databases have been properly set up.

I believe to run in development or test mode you must run the setup script without the -p flag to create the databases and then for the gems run the rake command with the proper RAILS_ENV.

script/setup
rake assets:precompile RAILS_ENV=development

You may also have to restart the rails server.

passenger start -a 0.0.0.0 -p 3000 -d -e development

Something different may have to be done now with the updated version of rails but I'm not sure.

kirantpatil commented 9 years ago

@joffems, can we have a simple automation script using v2 webapi ?

agramian commented 9 years ago

@kirantpatil can you be more specific? What language and what are you trying to do? The v2 API provides very detailed error messages. Are you not able to even send and receive a request? You van even test it with a GUI tool like API kitchen.

kirantpatil commented 9 years ago

@agramian, I need a simple script to as shown in http://news.testcasedb.com/wp-content/uploads/2012/05/automation_example1.pdf for testing GUI. I have no idea of how to access them and come up with a automated script.

I will check with API kitchen.

Thanks.

kirantpatil commented 9 years ago

I would like to use ruby to automate.

agramian commented 9 years ago

First of all @kirantpatil let's go back to your first example.

If you look at https://github.com/msjit/testcasedb/blob/master/spec/webapi/versions_api_spec.rb you will find example usage of the versions endpoint.

Your code should be revised as follows and it should work.

contents of command.json:

{
"version": "1.2.3",
"api_key": "oMPIgICN9KXsDhGgxfh"
}

curl command to TestCaseDB v2 web api

curl -k --data-ascii @command.json https://178.79.180.79/api/versions/search.json
kiranfractal commented 9 years ago

@agramian, yes now it worked. Thanks a lot.