mirror of
https://github.com/cmur2/dyndnsd.git
synced 2024-11-14 16:56:14 +01:00
Update spec
This commit is contained in:
parent
315e460c28
commit
d46f226e32
@ -14,7 +14,7 @@ describe Dyndnsd::Daemon do
|
||||
}
|
||||
db = Dyndnsd::DummyDatabase.new({})
|
||||
updater = Dyndnsd::Updater::Dummy.new
|
||||
responder = Dyndnsd::Responder::RestStyle.new
|
||||
responder = Dyndnsd::Responder::DynDNSStyle.new
|
||||
app = Dyndnsd::Daemon.new(config, db, updater, responder)
|
||||
|
||||
Rack::Auth::Basic.new(app, "DynDNS") do |user,pass|
|
||||
@ -25,6 +25,9 @@ describe Dyndnsd::Daemon do
|
||||
it 'requires authentication' do
|
||||
get '/'
|
||||
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
|
||||
|
||||
it 'only supports GET requests' do
|
||||
@ -42,13 +45,15 @@ describe Dyndnsd::Daemon do
|
||||
it 'requires the hostname query parameter' do
|
||||
authorize 'test', 'secret'
|
||||
get '/nic/update'
|
||||
last_response.status.should == 422
|
||||
last_response.should be_ok
|
||||
last_response.body.should == 'notfqdn'
|
||||
end
|
||||
|
||||
it 'forbids changing hosts a user does not own' do
|
||||
authorize 'test', 'secret'
|
||||
get '/nic/update?hostname=notmyhost.example.org'
|
||||
last_response.status.should == 403
|
||||
last_response.should be_ok
|
||||
last_response.body.should == 'nohost'
|
||||
end
|
||||
|
||||
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'
|
||||
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.body.should == 'Good'
|
||||
last_response.body.should == 'good 1.2.3.40'
|
||||
end
|
||||
|
||||
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'
|
||||
last_response.should be_ok
|
||||
last_response.body.should == 'No change'
|
||||
last_response.body.should == 'nochg 1.2.3.4'
|
||||
end
|
||||
|
||||
it 'forbids invalid hostnames' do
|
||||
|
Loading…
Reference in New Issue
Block a user