Skip to content

Commit

Permalink
fix backward compatibility for member add to uaa 1.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
daleolds committed Feb 12, 2013
1 parent 1267c14 commit 001b7d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/cli/common.rb
Expand Up @@ -83,9 +83,12 @@ def update_target_info(info = nil)
def scim_common_list(type, filter) def scim_common_list(type, filter)
pp scim_request { |sr| pp scim_request { |sr|
query = { attributes: opts[:attrs], filter: filter } query = { attributes: opts[:attrs], filter: filter }
opts[:start] || opts[:count] ? info = opts[:start] || opts[:count] ?
sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count])): sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count])):
sr.all_pages(type, query) sr.all_pages(type, query)
nattr = sr.name_attr(type).downcase
info.is_a?(Array) && info.length > 0 && info[0][nattr] ?
info.each_with_object({}) { |v, h| h[v.delete(nattr)] = v } : info
} }
end end


Expand All @@ -94,7 +97,9 @@ def scim_get_object(scim, type, name, attrs = nil)
info = scim.all_pages(type, query) info = scim.all_pages(type, query)
raise BadResponse unless info.is_a?(Array) && info.length < 2 raise BadResponse unless info.is_a?(Array) && info.length < 2
raise NotFound if info.length == 0 raise NotFound if info.length == 0
info[0] info = info[0]
# when getting whole object, handle case of UAA < 1.3 which did not return meta attr from query
attrs || !info["id"] || info["meta"]? info : scim.get(type, info["id"])
end end
end end


Expand Down
2 changes: 1 addition & 1 deletion lib/cli/version.rb
Expand Up @@ -14,6 +14,6 @@
# Cloud Foundry namespace # Cloud Foundry namespace
module CF module CF
module UAA module UAA
CLI_VERSION = "1.3.8" CLI_VERSION = "1.3.9"
end end
end end
2 changes: 0 additions & 2 deletions spec/group_spec.rb
Expand Up @@ -54,7 +54,6 @@ module CF::UAA
Cli.output.string.should include @test_group Cli.output.string.should include @test_group
Cli.run("group get #{@test_group.upcase}").should be Cli.run("group get #{@test_group.upcase}").should be
Cli.output.string.should include @test_group Cli.output.string.should include @test_group
pending "real uaa can't add members to scim.read group yet" unless @stub_uaa
Cli.run("member add scim.read #{@test_user}w").should be Cli.run("member add scim.read #{@test_user}w").should be
end end


Expand Down Expand Up @@ -109,7 +108,6 @@ def check_members


it "adds one writer to the group" do it "adds one writer to the group" do
Cli.run("group writer add #{@test_group} #{@test_user}w").should be Cli.run("group writer add #{@test_group} #{@test_user}w").should be
Cli.run("group reader add #{@test_group} #{@test_user}w").should be
Cli.output.string.should include "success" Cli.output.string.should include "success"
end end


Expand Down
2 changes: 1 addition & 1 deletion spec/setup_helper.rb
Expand Up @@ -18,7 +18,7 @@


client = ENV["UAA_CLIENT_ID"] || "admin" client = ENV["UAA_CLIENT_ID"] || "admin"
secret = ENV["UAA_CLIENT_SECRET"] || "adminsecret" secret = ENV["UAA_CLIENT_SECRET"] || "adminsecret"
abort("UAA_CLIENT_TARGET is not set") unless target = ENV["UAA_CLIENT_TARGET"] target = ENV["UAA_CLIENT_TARGET"] || "http://localhost:8080/uaa"


[ [
"target #{target}", "target #{target}",
Expand Down

0 comments on commit 001b7d2

Please sign in to comment.