45 lines
1.6 KiB
Ruby
45 lines
1.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe IcecastAdminAuthentication do
|
|
|
|
let(:admin) { IcecastAdminAuthentication.new }
|
|
let(:output) { StringIO.new }
|
|
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
|
|
|
|
it "save error" do
|
|
admin.save.should be_false
|
|
admin.errors[:source_password].length.should == 2
|
|
admin.errors[:admin_user].length.should == 2
|
|
admin.errors[:admin_password].length.should == 2
|
|
admin.errors[:relay_user].length.should == 2
|
|
admin.errors[:relay_password].length.should == 2
|
|
end
|
|
|
|
it "save" do
|
|
admin.source_password = Faker::Lorem.characters(10)
|
|
admin.admin_user = Faker::Lorem.characters(10)
|
|
admin.admin_password = Faker::Lorem.characters(10)
|
|
admin.relay_user = Faker::Lorem.characters(10)
|
|
admin.relay_password = Faker::Lorem.characters(10)
|
|
|
|
admin.save.should be_true
|
|
|
|
admin.dumpXml(builder)
|
|
|
|
output.rewind
|
|
|
|
xml = Nokogiri::XML(output)
|
|
xml.css('authentication source-password').text.should == admin.source_password
|
|
xml.css('authentication source-password').length.should == 1
|
|
xml.css('authentication admin-user').text.should == admin.admin_user
|
|
xml.css('authentication admin-user').length.should == 1
|
|
xml.css('authentication relay-user').text.should == admin.relay_user
|
|
xml.css('authentication relay-user').length.should == 1
|
|
xml.css('authentication relay-password').text.should == admin.relay_password
|
|
xml.css('authentication relay-password').length.should == 1
|
|
xml.css('authentication admin-password').text.should == admin.admin_password
|
|
xml.css('authentication admin-password').length.should == 1
|
|
end
|
|
|
|
end
|