|
151 | 151 | context "with pending members" do |
152 | 152 | let(:org1_members_response) do |
153 | 153 | { |
154 | | - "toyger" => "admin", |
155 | | - "highlander" => "admin", |
156 | | - "blackmanx" => "member", |
157 | | - "russianblue" => "member" |
| 154 | + "toyger" => "admin", |
| 155 | + "highlander" => "admin", |
| 156 | + "blackmanx" => "member", |
| 157 | + "russianblue" => "member" |
158 | 158 | } |
159 | 159 | end |
160 | 160 |
|
161 | 161 | let(:org1_pending_members) { Set.new(%w[ragamuffin peterbald]) } |
162 | 162 |
|
163 | 163 | let(:org2_members_response) do |
164 | 164 | { |
165 | | - "russianblue" => "admin" |
| 165 | + "russianblue" => "admin" |
166 | 166 | } |
167 | 167 | end |
168 | 168 |
|
|
182 | 182 |
|
183 | 183 | it "logs expected output and returns expected actions" do |
184 | 184 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
185 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 185 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
186 | 186 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
187 | 187 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
188 | 188 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
267 | 267 |
|
268 | 268 | it "logs expected output and returns expected actions" do |
269 | 269 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
270 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 270 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
271 | 271 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
272 | 272 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
273 | 273 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
318 | 318 | { |
319 | 319 | "ragamuffin" => "admin", |
320 | 320 | "mainecoon" => "admin", |
321 | | - "blackmanx" => "member", |
322 | | - "highlander" => "member", |
| 321 | + "blackmanx" => "member", |
| 322 | + "highlander" => "member", |
323 | 323 | "peterbald" => "member" |
324 | 324 | } |
325 | 325 | end |
326 | 326 |
|
327 | 327 | let(:org2_members_response) do |
328 | 328 | { |
329 | | - "russianblue" => "admin" |
| 329 | + "russianblue" => "admin" |
330 | 330 | } |
331 | 331 | end |
332 | 332 |
|
333 | 333 | it "does not run actions" do |
334 | 334 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
335 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 335 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
336 | 336 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
337 | 337 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
338 | 338 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
378 | 378 |
|
379 | 379 | it "handles removals and role changes but does not invite" do |
380 | 380 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
381 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "features"=>%w[remove], "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 381 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "features" => %w[remove], "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
382 | 382 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
383 | 383 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
384 | 384 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
414 | 414 | "MAINECOON" |
415 | 415 | ])) |
416 | 416 | expect(result[0].implementation).to eq([ |
417 | | - { action: :add, person: "RagaMuffin"}, |
418 | | - { action: :remove, person: "russianblue"} |
| 417 | + { action: :add, person: "RagaMuffin" }, |
| 418 | + { action: :remove, person: "russianblue" } |
419 | 419 | ]) |
420 | 420 |
|
421 | 421 | expect(result[1]).to be_a_kind_of(Entitlements::Models::Action) |
|
425 | 425 | "peterbald" |
426 | 426 | ])) |
427 | 427 | expect(result[1].implementation).to eq([ |
428 | | - { action: :remove, person: "toyger"} |
| 428 | + { action: :remove, person: "toyger" } |
429 | 429 | ]) |
430 | 430 | end |
431 | 431 | end |
|
441 | 441 |
|
442 | 442 | it "reports as a no-op" do |
443 | 443 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
444 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "features"=>%w[remove], "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 444 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "features" => %w[remove], "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
445 | 445 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
446 | 446 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
447 | 447 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
490 | 490 |
|
491 | 491 | it "handles removals and role changes but does not invite" do |
492 | 492 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
493 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "features"=>%w[invite], "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 493 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "features" => %w[invite], "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
494 | 494 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
495 | 495 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
496 | 496 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
527 | 527 | "MAINECOON" |
528 | 528 | ])) |
529 | 529 | expect(result[0].implementation).to eq([ |
530 | | - { action: :add, person: "RagaMuffin"} |
| 530 | + { action: :add, person: "RagaMuffin" } |
531 | 531 | ]) |
532 | 532 |
|
533 | 533 | expect(result[1]).to be_a_kind_of(Entitlements::Models::Action) |
|
539 | 539 | "peterbald" |
540 | 540 | ])) |
541 | 541 | expect(result[1].implementation).to eq([ |
542 | | - { action: :add, person: "blackmanx"} |
| 542 | + { action: :add, person: "blackmanx" } |
543 | 543 | ]) |
544 | 544 | end |
545 | 545 | end |
|
559 | 559 |
|
560 | 560 | it "reports as a no-op" do |
561 | 561 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
562 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "features"=>%w[invite], "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 562 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "features" => %w[invite], "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
563 | 563 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
564 | 564 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
565 | 565 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
595 | 595 | cache[:predictive_state] = { by_dn: { org1_admin_dn => { members: admins, metadata: nil }, org1_member_dn => { members:, metadata: nil } }, invalid: Set.new } |
596 | 596 |
|
597 | 597 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
598 | | - .with("foo-githuborg", { "base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 598 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
599 | 599 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
600 | 600 |
|
601 | 601 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
|
666 | 666 |
|
667 | 667 | it "handles removals and role changes but does not invite" do |
668 | 668 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
669 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "features"=>[], "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 669 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "features" => [], "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
670 | 670 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
671 | 671 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
672 | 672 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
702 | 702 | "MAINECOON" |
703 | 703 | ])) |
704 | 704 | expect(result[0].implementation).to eq([ |
705 | | - { action: :add, person: "RagaMuffin"} |
| 705 | + { action: :add, person: "RagaMuffin" } |
706 | 706 | ]) |
707 | 707 |
|
708 | 708 | expect(result[1]).to be_a_kind_of(Entitlements::Models::Action) |
|
729 | 729 |
|
730 | 730 | it "reports as a no-op" do |
731 | 731 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
732 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "features"=>[], "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 732 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "features" => [], "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
733 | 733 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
734 | 734 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_admin_dn).and_return(org1_admin_group) |
735 | 735 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(org1_member_dn).and_return(org1_member_group) |
|
840 | 840 | describe "#validate_github_org_ous!" do |
841 | 841 | it "raises if an admin or member group is missing" do |
842 | 842 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
843 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 843 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
844 | 844 | .and_return(Set.new(%w[member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
845 | 845 |
|
846 | 846 | github_double = instance_double(Entitlements::Backend::GitHubOrg::Provider) |
|
860 | 860 | dns = %w[admin member kittens cats].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" } |
861 | 861 |
|
862 | 862 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
863 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 863 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
864 | 864 | .and_return(Set.new(dns)) |
865 | 865 |
|
866 | 866 | allow(Entitlements::Backend::GitHubOrg::Service).to receive(:new).and_return(service) |
|
900 | 900 |
|
901 | 901 | it "raises due to duplicate users" do |
902 | 902 | allow(Entitlements::Data::Groups::Calculated).to receive(:read_all) |
903 | | - .with("foo-githuborg", {"base"=>"ou=kittensinc,ou=GitHub,dc=github,dc=com", "org"=>"kittensinc", "token"=>"CuteAndCuddlyKittens", "ignore_not_found"=>false}) |
| 903 | + .with("foo-githuborg", { "base" => "ou=kittensinc,ou=GitHub,dc=github,dc=com", "org" => "kittensinc", "token" => "CuteAndCuddlyKittens", "ignore_not_found" => false }) |
904 | 904 | .and_return(Set.new(%w[admin member].map { |cn| "cn=#{cn},ou=kittensinc,ou=GitHub,dc=github,dc=com" })) |
905 | 905 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(admin_dn).and_return(admin_group) |
906 | 906 | allow(Entitlements::Data::Groups::Calculated).to receive(:read).with(member_dn).and_return(member_group) |
|
0 commit comments