-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for domain_ownership logic
- Loading branch information
Showing
5 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "test_helper" | ||
|
||
class DomainOwnershipServiceTest < ActiveSupport::TestCase | ||
def setup | ||
@identity = Identity.new(subject: "[email protected]", groups: ["admin_group"]) | ||
Check failure on line 5 in test/lib/services/domain_ownership_service_test.rb GitHub Actions / lint
|
||
@domain = DomainInfo.new(owner: "[email protected]", group_delegation: false, groups: ["admin_group"]) | ||
Check failure on line 6 in test/lib/services/domain_ownership_service_test.rb GitHub Actions / lint
|
||
end | ||
|
||
test "#authorize! with matching owner" do | ||
ds = Services::DomainOwnershipService.new | ||
ds.stub :get_domain_name, @domain do | ||
assert_nil(ds.authorize!(@identity, CertIssueRequest.new)) | ||
end | ||
end | ||
|
||
test "#authorize! with non-matching owner" do | ||
ds = Services::DomainOwnershipService.new | ||
@domain.owner = "[email protected]" | ||
ds.stub :get_domain_name, @domain do | ||
assert_raises(AuthError) do | ||
ds.authorize!(@identity, CertIssueRequest.new) | ||
end | ||
end | ||
end | ||
|
||
test "#authorize! with matching group" do | ||
ds = Services::DomainOwnershipService.new | ||
@domain.owner = "[email protected]" | ||
@domain.group_delegation = true | ||
ds.stub :get_domain_name, @domain do | ||
assert_nil(ds.authorize!(@identity, CertIssueRequest.new)) | ||
end | ||
end | ||
|
||
test "#authorize! with non-matching group" do | ||
ds = Services::DomainOwnershipService.new | ||
@domain.owner = "[email protected]" | ||
@identity.groups = ["different_group"] | ||
Check failure on line 38 in test/lib/services/domain_ownership_service_test.rb GitHub Actions / lint
|
||
ds.stub :get_domain_name, @domain do | ||
assert_raises(AuthError) do | ||
ds.authorize!(@identity, CertIssueRequest.new) | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters