Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added tests for DELETE * Renamed to PSigner internally * Removed undeeded configuration sets * Changed api to /api/cert globally
- Loading branch information
Showing
7 changed files
with
54 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,3 @@ | |||
require './lib/psigner/app.rb' | require './lib/psigner/app.rb' | ||
|
|
||
run Psigner::Application | run PSigner::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,3 @@ | |||
module Psigner | module PSigner | ||
VERSION = "0.0.1" | VERSION = "0.0.1" | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,33 +1,58 @@ | |||
require 'spec_helper' | require 'spec_helper' | ||
|
|
||
describe Psigner::Application do | describe PSigner::Application do | ||
|
|
||
describe "GET '/api/sign'" do | describe "GET '/api/cert'" do | ||
it "should fail" do | it "should fail" do | ||
get '/' | get '/' | ||
last_response.should_not be_ok | last_response.should_not be_ok | ||
end | end | ||
end | end | ||
|
|
||
describe "POST '/api/sign'" do | describe "POST '/api/cert'" do | ||
it "should fail to get the API signing page without parameters" do | it "should fail to sign the cert without parameters" do | ||
post '/api/sign' | post '/api/cert' | ||
last_response.status.should == 400 | last_response.status.should == 401 | ||
end | end | ||
|
|
||
it "should fail to get the API signing page with only one parameter" do | it "should fail to sign via the API with only one parameter" do | ||
post '/api/sign', params = { "secret" => "SHAREDSECRET" } | post '/api/cert', params = { "secret" => "SHAREDSECRET" } | ||
last_response.status.should == 400 | last_response.status.should == 400 | ||
end | end | ||
|
|
||
it "should get the API signing page" do | it "should fail with incorrect shared secret" do | ||
post '/api/sign', params = { "secret" => "SHAREDSECRET", "certname" => "bob" } | post '/api/cert', params = { "secret" => "NOSHAREDSECRET", "certname" => "bob" } | ||
last_response.status.should == 401 | |||
end | |||
|
|||
it "should sign via the API with correct parameters" do | |||
post '/api/cert', params = { "secret" => "SHAREDSECRET", "certname" => "bob" } | |||
last_response.status.should == 200 | last_response.status.should == 200 | ||
end | end | ||
|
|
||
end | |||
|
|||
describe "DELETE '/api/cert'" do | |||
it "should fail to delete the cert without parameters" do | |||
delete '/api/cert' | |||
last_response.status.should == 401 | |||
end | |||
|
|||
it "should fail to delete the cert with only one parameter" do | |||
delete '/api/cert', params = { "secret" => "SHAREDSECRET" } | |||
last_response.status.should == 400 | |||
end | |||
|
|||
it "should fail with incorrect shared secret" do | it "should fail with incorrect shared secret" do | ||
post '/api/sign', params = { "secret" => "NOSHAREDSECRET", "certname" => "bob" } | delete '/api/cert', params = { "secret" => "NOSHAREDSECRET", "certname" => "bob" } | ||
last_response.status.should == 401 | last_response.status.should == 401 | ||
end | end | ||
|
|||
it "should delete via the API with correct parameters" do | |||
delete '/api/cert', params = { "secret" => "SHAREDSECRET", "certname" => "bob" } | |||
last_response.status.should == 200 | |||
end | |||
|
|||
|
|||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters