1
0
mirror of https://github.com/cmur2/dyndnsd.git synced 2024-12-22 00:54:22 +01:00

Update spec

This commit is contained in:
cn 2013-04-27 14:37:52 +02:00
parent 315e460c28
commit d46f226e32

View File

@ -14,7 +14,7 @@ describe Dyndnsd::Daemon do
} }
db = Dyndnsd::DummyDatabase.new({}) db = Dyndnsd::DummyDatabase.new({})
updater = Dyndnsd::Updater::Dummy.new updater = Dyndnsd::Updater::Dummy.new
responder = Dyndnsd::Responder::RestStyle.new responder = Dyndnsd::Responder::DynDNSStyle.new
app = Dyndnsd::Daemon.new(config, db, updater, responder) app = Dyndnsd::Daemon.new(config, db, updater, responder)
Rack::Auth::Basic.new(app, "DynDNS") do |user,pass| Rack::Auth::Basic.new(app, "DynDNS") do |user,pass|
@ -25,6 +25,9 @@ describe Dyndnsd::Daemon do
it 'requires authentication' do it 'requires authentication' do
get '/' get '/'
last_response.status.should == 401 last_response.status.should == 401
pending 'Need to find a way to add custom body on 401 responses'
last_response.should be_ok 'badauth'
end end
it 'only supports GET requests' do it 'only supports GET requests' do
@ -42,13 +45,15 @@ describe Dyndnsd::Daemon do
it 'requires the hostname query parameter' do it 'requires the hostname query parameter' do
authorize 'test', 'secret' authorize 'test', 'secret'
get '/nic/update' get '/nic/update'
last_response.status.should == 422 last_response.should be_ok
last_response.body.should == 'notfqdn'
end end
it 'forbids changing hosts a user does not own' do it 'forbids changing hosts a user does not own' do
authorize 'test', 'secret' authorize 'test', 'secret'
get '/nic/update?hostname=notmyhost.example.org' get '/nic/update?hostname=notmyhost.example.org'
last_response.status.should == 403 last_response.should be_ok
last_response.body.should == 'nohost'
end end
it 'updates a host on change' do it 'updates a host on change' do
@ -57,9 +62,9 @@ describe Dyndnsd::Daemon do
get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
last_response.should be_ok last_response.should be_ok
get '/nic/update?hostname=foo.example.org&myip=1.2.3.400' get '/nic/update?hostname=foo.example.org&myip=1.2.3.40'
last_response.should be_ok last_response.should be_ok
last_response.body.should == 'Good' last_response.body.should == 'good 1.2.3.40'
end end
it 'returns no change' do it 'returns no change' do
@ -70,7 +75,7 @@ describe Dyndnsd::Daemon do
get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4'
last_response.should be_ok last_response.should be_ok
last_response.body.should == 'No change' last_response.body.should == 'nochg 1.2.3.4'
end end
it 'forbids invalid hostnames' do it 'forbids invalid hostnames' do