refactoring: fix some rubocop issues
This commit is contained in:
parent
d5a3800577
commit
ad82caffda
2 changed files with 10 additions and 6 deletions
|
|
@ -18,10 +18,7 @@ module DiasporaFederation
|
|||
def fetch_and_save
|
||||
logger.info "Fetch data for #{diaspora_id}"
|
||||
|
||||
unless diaspora_id == clean_diaspora_id(webfinger.acct_uri)
|
||||
raise DiscoveryError, "Diaspora ID does not match: Wanted #{diaspora_id} but got" \
|
||||
" #{clean_diaspora_id(webfinger.acct_uri)}"
|
||||
end
|
||||
validate_diaspora_id
|
||||
|
||||
DiasporaFederation.callbacks.trigger(:save_person_after_webfinger, person)
|
||||
logger.info "successfully webfingered #{diaspora_id}"
|
||||
|
|
@ -30,6 +27,13 @@ module DiasporaFederation
|
|||
|
||||
private
|
||||
|
||||
def validate_diaspora_id
|
||||
# validates if the diaspora ID matches the diaspora ID in the webfinger response
|
||||
return if diaspora_id == clean_diaspora_id(webfinger.acct_uri)
|
||||
raise DiscoveryError, "Diaspora ID does not match: Wanted #{diaspora_id} but got" \
|
||||
" #{clean_diaspora_id(webfinger.acct_uri)}"
|
||||
end
|
||||
|
||||
def clean_diaspora_id(diaspora_id)
|
||||
diaspora_id.strip.sub("acct:", "").to_s.downcase
|
||||
end
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ module DiasporaFederation
|
|||
it "should fail in production if the certificate_authorities file is missing" do
|
||||
::Rails.env = "production"
|
||||
DiasporaFederation.certificate_authorities = "/unknown"
|
||||
expect { DiasporaFederation.validate_config }.to raise_error ConfigurationError,
|
||||
"certificate_authorities: File not found: /unknown"
|
||||
expect { DiasporaFederation.validate_config }
|
||||
.to raise_error ConfigurationError, "certificate_authorities: File not found: /unknown"
|
||||
end
|
||||
|
||||
after do
|
||||
|
|
|
|||
Loading…
Reference in a new issue