Commit 73df7adb authored by James Lopez's avatar James Lopez

update saml identity finder

parent 92dc05c4
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
class GroupSamlIdentityFinder class GroupSamlIdentityFinder
attr_reader :user attr_reader :user
def self.find_by_group_and_uid(group:, uid:)
group&.saml_provider&.identities&.find_by_extern_uid(uid)
end
def initialize(user:) def initialize(user:)
@user = user @user = user
end end
......
...@@ -11,6 +11,22 @@ describe GroupSamlIdentityFinder do ...@@ -11,6 +11,22 @@ describe GroupSamlIdentityFinder do
subject { described_class.new(user: user) } subject { described_class.new(user: user) }
describe ".find_by_group_and_uid" do
it "finds identity matching user and group" do
expect(described_class.find_by_group_and_uid(group: group, uid: identity.extern_uid)).to eq(identity)
end
it "returns nil when no saml_provider exists" do
group.saml_provider.destroy!
expect(described_class.find_by_group_and_uid(group: group, uid: identity.extern_uid)).to eq(nil)
end
it "returns nil when group is nil" do
expect(described_class.find_by_group_and_uid(group: nil, uid: identity.extern_uid)).to eq(nil)
end
end
describe "#find_linked" do describe "#find_linked" do
it "finds identity matching user and group" do it "finds identity matching user and group" do
expect(subject.find_linked(group: group)).to eq(identity) expect(subject.find_linked(group: group)).to eq(identity)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment