Skip to content

Commit

Permalink
Added quick test server for cli testing
Browse files Browse the repository at this point in the history
  • Loading branch information
phillmv committed Feb 20, 2016
1 parent 8642717 commit 0c13eec
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -6,3 +6,4 @@ gem "rake"
gem "rest-client"
gem "package_cloud"
gem 'pry'
gem 'sinatra'
11 changes: 10 additions & 1 deletion Gemfile.lock
Expand Up @@ -34,13 +34,21 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack-protection (1.5.3)
rack
rake (10.4.2)
rdoc (4.2.0)
rest-client (1.6.8)
mime-types (~> 1.16)
rdoc (>= 2.4.2)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
thor (0.19.1)
tilt (2.0.2)

PLATFORMS
ruby
Expand All @@ -51,6 +59,7 @@ DEPENDENCIES
pry
rake
rest-client
sinatra

BUNDLED WITH
1.10.1
1.10.6
33 changes: 33 additions & 0 deletions test/test_server.rb
@@ -0,0 +1,33 @@
require 'sinatra'
require 'json'
require 'pry'
require 'base64'

def print_bod(body)
bod = JSON.load(body.read)
puts "#" * 10
if bod["contents"]
bod["contents"] = Base64.decode64(bod["contents"])
end
puts bod
puts "#" * 10
end

get '/' do
"Hello world"
end

post '/api/v1/agent/heartbeat/:id' do
print_bod(request.body)
{success: true}.to_json
end

post '/api/v1/agent/servers' do
print_bod(request.body)
{uuid:"12345"}.to_json
end

put '/api/v1/agent/servers/:id' do
print_bod(request.body)
"OK"
end

0 comments on commit 0c13eec

Please sign in to comment.