Skip to content

Commit

Permalink
ignore SUSE Manager services in SLP discovery (bnc#894470)
Browse files Browse the repository at this point in the history
- 3.1.114
  • Loading branch information
lslezak committed Sep 1, 2014
1 parent 218d763 commit 4ab1e74
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
6 changes: 6 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Sep 1 17:21:41 UTC 2014 - lslezak@suse.cz

- ignore SUSE Manager services in SLP discovery (bnc#894470)
- 3.1.114

-------------------------------------------------------------------
Mon Sep 1 09:42:45 UTC 2014 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.1.113
Version: 3.1.114
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
9 changes: 4 additions & 5 deletions src/lib/registration/url_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,13 @@ def self.slp_service_url
end

def self.slp_discovery
services = []

log.info "Searching for #{SLP_SERVICE} SLP services"
services.concat(Yast::SlpService.all(SLP_SERVICE))
services = Yast::SlpService.all(SLP_SERVICE)

log.debug "Found services: #{services.inspect}"
log.info "Found #{services.size} services: #{services.map(&:slp_url).inspect}"
# ignore SUSE manager registration servers (bnc#894470)
services.reject!{ |service| service.slp_url.start_with?("service:#{SLP_SERVICE}:manager:") }

log.info "Found #{services.size} services: #{services.map(&:slp_url).inspect}"
services
end

Expand Down
2 changes: 1 addition & 1 deletion test/discover_registration_services_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
slp_attributes = double
allow(slp_attributes).to receive(:to_h).and_return({:description => "Description"})
allow(slp_service).to receive(:attributes).and_return(slp_attributes)
allow(slp_service).to receive(:slp_url).and_return("service:registration.suse:manager:#{slp_url}")
allow(slp_service).to receive(:slp_url).and_return("service:registration.suse:smt:#{slp_url}")
allow(slpservice).to receive(:all).and_return([slp_service])
end

Expand Down
37 changes: 37 additions & 0 deletions test/url_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,41 @@
end
end

describe ".slp_discovery" do
let(:slpservice) { double("Yast::SlpService") }

before do
stub_const("Yast::SlpService", slpservice)
end

it "returns SLP services excluding SUSE Manager services" do
service1 = double(:slp_url => "service:registration.suse:smt:https://example.com/connect")
service2 = double(:slp_url => "service:registration.suse:manager:https://example.com/connect")
expect(slpservice).to receive(:all).and_return([service1, service2])

# SUSE manager service (service2) is ignored
expect(Registration::UrlHelpers.slp_discovery).to eql([service1])
end
end

describe ".slp_discovery_feedback" do
let(:slpservice) { double("Yast::SlpService") }
let(:popup) { double("Yast::Popup") }

before do
stub_const("Yast::SlpService", slpservice)
stub_const("Yast::Popup", popup)
end

it "runs SLP discovery with progress message" do
services = [ double(:slp_url => "service:registration.suse:smt:https://example.com/connect") ]
expect(slpservice).to receive(:all).and_return(services)

# stub Popup.Feedback call but yield the passed block
expect(popup).to receive(:Feedback).and_yield()

expect(Registration::UrlHelpers.slp_discovery_feedback).to eql(services)
end
end

end

0 comments on commit 4ab1e74

Please sign in to comment.