1
0
mirror of https://github.com/cmur2/dyndnsd.git synced 2025-06-26 02:30:22 +02:00

responder: refactor into Rack middleware and improve API conformance

This commit is contained in:
cn
2018-02-01 20:26:48 +01:00
parent 3f56070ed5
commit f1b58f5167
4 changed files with 111 additions and 40 deletions

View File

@ -18,20 +18,18 @@ describe Dyndnsd::Daemon do
}
db = Dyndnsd::DummyDatabase.new({})
updater = Dyndnsd::Updater::Dummy.new
responder = Dyndnsd::Responder::DynDNSStyle.new
app = Dyndnsd::Daemon.new(config, db, updater, responder)
app = Dyndnsd::Daemon.new(config, db, updater)
Rack::Auth::Basic.new(app, "DynDNS") do |user,pass|
app = Rack::Auth::Basic.new(app, "DynDNS") do |user,pass|
(config['users'].has_key? user) and (config['users'][user]['password'] == pass)
end
app = Dyndnsd::Responder::DynDNSStyle.new(app)
end
it 'requires authentication' do
get '/'
expect(last_response.status).to eq(401)
pending 'Need to find a way to add custom body on 401 responses'
expect(last_response).not_to be_ok
expect(last_response.body).to eq('badauth')
end