Merge pull request #126 from SuperTux88/gem-updates

Gem updates
This commit is contained in:
Benjamin Neff 2022-07-18 02:32:44 +02:00
commit 52645df755
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
37 changed files with 215 additions and 281 deletions

View file

@ -1,4 +1,3 @@
<<<<<<< HEAD
# 0.3.0
## Breaking changes

14
Gemfile
View file

@ -20,9 +20,9 @@ end
group :development do
# code style
gem "pronto", "0.11.0", require: false
gem "pronto-rubocop", "0.11.1", require: false
gem "rubocop", "1.23.0", require: false
gem "rubocop-rails", "2.12.4", require: false
gem "pronto-rubocop", "0.11.2", require: false
gem "rubocop", "1.31.2", require: false
gem "rubocop-rails", "2.15.2", require: false
gem "rubocop-rake", "0.6.0", require: false
# debugging
@ -43,10 +43,10 @@ group :test do
# test coverage
gem "simplecov", "0.21.2", require: false
gem "simplecov-rcov", "0.2.3", require: false
gem "simplecov-rcov", "0.3.1", require: false
# test helpers
gem "json-schema-rspec", "0.0.4"
gem "json-schema", "~> 3.0"
gem "rspec-collection_matchers", "~> 1.2.0"
gem "rspec-json_expectations", "~> 2.1"
gem "webmock", "~> 3.0"
@ -56,6 +56,6 @@ group :development, :test do
gem "rake"
# unit tests
gem "rspec", "~> 3.10.0"
gem "rspec-rails", "~> 5.0.1"
gem "rspec", "~> 3.11.0"
gem "rspec-rails", "~> 5.1.2"
end

View file

@ -2,101 +2,83 @@ PATH
remote: .
specs:
diaspora_federation (0.3.0)
faraday (~> 1.0)
faraday_middleware (~> 1.0)
faraday (>= 1.0, < 3)
faraday-follow_redirects (~> 0.3)
nokogiri (~> 1.6, >= 1.6.8)
typhoeus (~> 1.0)
valid (~> 1.0)
diaspora_federation-json_schema (0.3.0)
diaspora_federation-rails (0.3.0)
actionpack (>= 5.2, < 7)
actionpack (>= 5.2, < 8)
diaspora_federation (= 0.3.0)
diaspora_federation-test (0.3.0)
diaspora_federation (= 0.3.0)
fabrication (~> 2.16)
fabrication (~> 2.29)
uuid (~> 2.3, >= 2.3.8)
GEM
remote: https://rubygems.org/
specs:
actionpack (6.1.4.1)
actionview (= 6.1.4.1)
activesupport (= 6.1.4.1)
rack (~> 2.0, >= 2.0.9)
actionpack (7.0.3.1)
actionview (= 7.0.3.1)
activesupport (= 7.0.3.1)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.1.4.1)
activesupport (= 6.1.4.1)
actionview (7.0.3.1)
activesupport (= 7.0.3.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (6.1.4.1)
activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
builder (3.2.4)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
crack (0.4.5)
rexml
crass (1.0.6)
diff-lcs (1.4.4)
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.10.0)
ethon (0.15.0)
ffi (>= 1.15.0)
fabrication (2.27.0)
faraday (1.8.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
fabrication (2.29.0)
faraday (2.3.0)
faraday-net_http (~> 2.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday_middleware (1.2.0)
faraday (~> 1.0)
ffi (1.15.4)
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (2.0.3)
ffi (1.15.5)
fuubar (2.5.1)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
gitlab (4.17.0)
httparty (~> 0.18)
terminal-table (~> 1.5, >= 1.5.1)
gitlab (4.19.0)
httparty (~> 0.20)
terminal-table (>= 1.5.1)
hashdiff (1.0.1)
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.11)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json-schema (2.8.1)
addressable (>= 2.4)
json-schema-rspec (0.0.4)
json-schema (~> 2.5)
rspec
listen (3.7.0)
json (2.6.2)
json-schema (3.0.0)
addressable (>= 2.8)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.12.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
macaddr (1.7.2)
@ -104,21 +86,20 @@ GEM
method_source (1.0.0)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115)
mime-types-data (3.2022.0105)
mini_portile2 (2.8.0)
minitest (5.14.4)
minitest (5.16.2)
multi_xml (0.6.0)
multipart-post (2.1.1)
nokogiri (1.13.3)
nokogiri (1.13.7)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nyan-cat-formatter (0.12.0)
rspec (>= 2.99, >= 2.14.2, < 4)
octokit (4.21.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
parallel (1.21.0)
parser (3.0.3.0)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pronto (0.11.0)
gitlab (~> 4.4, >= 4.4.0)
@ -128,54 +109,55 @@ GEM
rexml (~> 3.2)
rugged (>= 0.23.0, < 1.1.0)
thor (>= 0.20.3, < 2.0)
pronto-rubocop (0.11.1)
pronto-rubocop (0.11.2)
pronto (~> 0.11.0)
rubocop (>= 0.63.1, < 2.0)
pry (0.14.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.8.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.10)
public_suffix (4.0.6)
pry (~> 0.13.0)
public_suffix (4.0.7)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack (2.2.4)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
railties (7.0.3.1)
actionpack (= 7.0.3.1)
activesupport (= 7.0.3.1)
method_source
rake (>= 0.13)
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.0.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.1.1)
regexp_parser (2.5.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-collection_matchers (1.2.0)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (~> 3.11.0)
rspec-json_expectations (2.2.0)
rspec-mocks (3.10.2)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (5.0.2)
rspec-support (~> 3.11.0)
rspec-rails (5.1.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
@ -183,19 +165,20 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.3)
rubocop (1.23.0)
rspec-support (3.11.0)
rubocop (1.31.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
rubocop-rails (2.12.4)
rubocop-ast (1.19.1)
parser (>= 3.1.1.0)
rubocop-rails (2.15.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
@ -204,25 +187,26 @@ GEM
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
rugged (1.0.1)
sawyer (0.8.2)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
faraday (>= 0.17.3, < 3)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-rcov (0.2.3)
simplecov-rcov (0.3.1)
simplecov (>= 0.4.1)
simplecov_json_formatter (0.1.3)
simplecov_json_formatter (0.1.4)
systemu (2.6.5)
terminal-table (1.6.0)
thor (1.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
unicode-display_width (2.2.0)
uuid (2.3.9)
macaddr (~> 1.0)
valid (1.2.0)
@ -230,8 +214,10 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
yard (0.9.26)
zeitwerk (2.5.1)
webrick (1.7.0)
yard (0.9.28)
webrick (~> 1.7.0)
zeitwerk (2.6.0)
PLATFORMS
ruby
@ -242,23 +228,23 @@ DEPENDENCIES
diaspora_federation-rails!
diaspora_federation-test!
fuubar (= 2.5.1)
json-schema-rspec (= 0.0.4)
json-schema (~> 3.0)
listen
nyan-cat-formatter
pronto (= 0.11.0)
pronto-rubocop (= 0.11.1)
pronto-rubocop (= 0.11.2)
pry
pry-byebug
rake
rspec (~> 3.10.0)
rspec (~> 3.11.0)
rspec-collection_matchers (~> 1.2.0)
rspec-json_expectations (~> 2.1)
rspec-rails (~> 5.0.1)
rubocop (= 1.23.0)
rubocop-rails (= 2.12.4)
rspec-rails (~> 5.1.2)
rubocop (= 1.31.2)
rubocop-rails (= 2.15.2)
rubocop-rake (= 0.6.0)
simplecov (= 0.21.2)
simplecov-rcov (= 0.2.3)
simplecov-rcov (= 0.3.1)
webmock (~> 3.0)
yard

View file

@ -15,8 +15,9 @@ module DiasporaFederation
if magic_env
render xml: magic_env, content_type: "application/magic-envelope+xml"
else
redirect_to DiasporaFederation.callbacks.trigger(:fetch_person_url_to,
entity.author, "/fetch/#{params[:type]}/#{params[:guid]}")
redirect_url = DiasporaFederation.callbacks.trigger(:fetch_person_url_to,
entity.author, "/fetch/#{params[:type]}/#{params[:guid]}")
redirect_to redirect_url, allow_other_host: true
end
else
head :not_found

View file

@ -2,12 +2,12 @@
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.
ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/diaspora_federation/engine', __dir__)
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path("../lib/diaspora_federation/engine", __dir__)
APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
require "rails/all"

View file

@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.email = ["benjamin@coding4.coffee", "senya@riseup.net"]
s.homepage = "https://github.com/diaspora/diaspora_federation"
s.summary = "diaspora* federation json schemas"
s.description = "This gem provides JSON schemas (currently one schema) for "\
s.description = "This gem provides JSON schemas (currently one schema) for " \
"validating JSON serialized federation objects."
s.license = "AGPL-3.0"
s.metadata = {

View file

@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.7"
s.add_dependency "actionpack", ">= 5.2", "< 7"
s.add_dependency "actionpack", ">= 5.2", "< 8"
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
end

View file

@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.email = ["benjamin@coding4.coffee"]
s.homepage = "https://github.com/diaspora/diaspora_federation"
s.summary = "diaspora* federation test utils"
s.description = "This gem provides some supplimentary code (factory definitions), that"\
s.description = "This gem provides some supplimentary code (factory definitions), that" \
"helps to build tests for users of the diaspora_federation gem."
s.license = "AGPL-3.0"
s.metadata = {
@ -25,6 +25,6 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.7"
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
s.add_dependency "fabrication", "~> 2.16"
s.add_dependency "fabrication", "~> 2.29"
s.add_dependency "uuid", "~> 2.3", ">= 2.3.8"
end

View file

@ -29,8 +29,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.7"
s.add_dependency "faraday", "~> 1.0"
s.add_dependency "faraday_middleware", "~> 1.0"
s.add_dependency "faraday", ">= 1.0", "< 3"
s.add_dependency "faraday-follow_redirects", "~> 0.3"
s.add_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
s.add_dependency "typhoeus", "~> 1.0"
s.add_dependency "valid", "~> 1.0"

View file

@ -38,8 +38,8 @@ module DiasporaFederation
# 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)}"
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)

View file

@ -136,10 +136,7 @@ module DiasporaFederation
private
# rubocop:disable Layout/EmptyLinesAroundAttributeAccessor Style/AccessorGrouping
attr_reader :expires
attr_reader :subject
# rubocop:enable Layout/EmptyLinesAroundAttributeAccessor Style/AccessorGrouping
attr_reader :expires, :subject
NS = {xrd: XMLNS}.freeze

View file

@ -131,7 +131,7 @@ module DiasporaFederation
data = super
order = signature_order
order += %i[author_signature] unless author == parent.root.author
order.map {|element| [element, data[element].to_s] }.to_h
order.to_h {|element| [element, data[element].to_s] }
end
def signature_order=(order)

View file

@ -77,7 +77,7 @@ module DiasporaFederation
# Nested entities are also converted to a Hash.
# @return [Hash] entity data (mostly equal to the hash used for initialization).
def to_h
enriched_properties.map {|key, value|
enriched_properties.to_h {|key, value|
type = self.class.class_props[key]
if type.instance_of?(Symbol) || value.nil?
@ -87,7 +87,7 @@ module DiasporaFederation
elsif type.instance_of?(Array)
[key, value.map(&:to_h)]
end
}.to_h
}
end
# Returns the XML representation for this entity constructed out of
@ -273,7 +273,7 @@ module DiasporaFederation
end
def normalized_properties
properties.map {|name, value| [name, normalize_property(name, value)] }.to_h
properties.to_h {|name, value| [name, normalize_property(name, value)] }
end
def normalize_property(name, value)

View file

@ -26,7 +26,7 @@ module DiasporaFederation
def self.private(sender_id, obj_str, targets)
hydra = HydraWrapper.new(sender_id, obj_str)
targets.each {|url, json| hydra.insert_enc_magic_env_request(url, json) }
hydra.send.map {|url| [url, targets[url]] }.to_h
hydra.send.to_h {|url| [url, targets[url]] }
end
end
end

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require "faraday"
require "faraday_middleware"
require "faraday/follow_redirects"
module DiasporaFederation
# A wrapper for {https://github.com/lostisland/faraday Faraday}
@ -32,7 +32,8 @@ module DiasporaFederation
}
@connection = Faraday::Connection.new(options) do |builder|
builder.response :follow_redirects, limit: DiasporaFederation.http_redirect_limit
builder.use Faraday::FollowRedirects::Middleware, limit: DiasporaFederation.http_redirect_limit
builder.adapter Faraday.default_adapter
end

View file

@ -17,7 +17,7 @@ module DiasporaFederation
private
def parse_entity_data(entity_data)
hash = entity_data.map {|key, value|
hash = entity_data.to_h {|key, value|
property = entity_type.class_props.keys.find {|name| name.to_s == key }
if property
type = entity_type.class_props[property]
@ -25,7 +25,7 @@ module DiasporaFederation
else
[key, value]
end
}.to_h
}
[hash]
end
@ -49,9 +49,7 @@ module DiasporaFederation
end
def from_json_sanity_validation(json_hash)
missing = %w[entity_type entity_data].map {|prop|
prop if json_hash[prop].nil?
}.compact.join(", ")
missing = %w[entity_type entity_data].select {|prop| json_hash[prop].nil? }.join(", ")
raise DeserializationError, "Required properties are missing in JSON object: #{missing}" unless missing.empty?
assert_parsability_of(json_hash["entity_type"])

View file

@ -14,7 +14,7 @@ module DiasporaFederation
def parse(root_node)
from_xml_sanity_validation(root_node)
hash = root_node.element_children.uniq(&:name).map {|child|
hash = root_node.element_children.uniq(&:name).to_h {|child|
property, type = find_property_for(child.name)
if property
value = parse_element_from_node(child.name, type, root_node)
@ -22,7 +22,7 @@ module DiasporaFederation
else
[child.name, child.text]
end
}.to_h
}
[hash]
end

View file

@ -57,7 +57,7 @@ module DiasporaFederation
# resolved on each call
# @return [Hash] default values
def default_values
optional_props.map {|name| [name, nil] }.to_h.merge(default_props).transform_values {|prop|
optional_props.to_h {|name| [name, nil] }.merge(default_props).transform_values {|prop|
prop.respond_to?(:call) ? prop.call : prop
}
end
@ -65,7 +65,7 @@ module DiasporaFederation
# @param [Hash] data entity data
# @return [Hash] hash with resolved aliases
def resolv_aliases(data)
data.map {|name, value|
data.to_h {|name, value|
if class_prop_aliases.has_key? name
prop_name = class_prop_aliases[name]
raise InvalidData, "only use '#{name}' OR '#{prop_name}'" if data.has_key? prop_name
@ -74,7 +74,7 @@ module DiasporaFederation
else
[name, value]
end
}.to_h
}
end
private

View file

@ -9,7 +9,7 @@ module DiasporaFederation
end
def build_instance
self._instance = _klass.new(_attributes)
self._instance = resolved_class.new(_attributes)
end
def to_hash(attributes=[], _callbacks=[])

View file

@ -117,9 +117,9 @@ module DiasporaFederation
it "returns a hash of the internal data" do
entity = Entities::TestDefaultEntity.new(data)
expect(entity.to_h).to eq(
data.map {|key, value|
data.to_h {|key, value|
[key, entity.class.class_props[key] == :string ? value.to_s : value]
}.to_h
}
)
end
end

View file

@ -33,7 +33,8 @@ module DiasporaFederation
stub_request(:get, "http://www.example.com")
.to_return(status: 302, headers: {"Location" => "http://www.example.com"})
expect { HttpClient.get("http://www.example.com") }.to raise_error FaradayMiddleware::RedirectLimitReached
expect { HttpClient.get("http://www.example.com") }
.to raise_error Faraday::FollowRedirects::RedirectLimitReached
end
it "uses the gem name as User-Agent" do

View file

@ -43,7 +43,7 @@ module DiasporaFederation
after do
DiasporaFederation.certificate_authorities = @certificate_authorities
::Rails.env = ENV["RAILS_ENV"] || "test"
::Rails.env = ENV.fetch("RAILS_ENV", "test")
end
end

View file

@ -29,7 +29,6 @@ else
end
# test helpers
require "json-schema-rspec"
require "rspec/collection_matchers"
require "rspec/json_expectations"
require "webmock/rspec"
@ -45,9 +44,6 @@ require "entities"
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f }
RSpec.configure do |config|
config.include JSON::SchemaMatchers
config.json_schemas[:entity_schema] = "lib/diaspora_federation/schemas/federation_entities.json"
config.example_status_persistence_file_path = "spec/rspec-persistence.txt"
config.expect_with :rspec do |expect_config|

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
require "json-schema"
def entity_hash_from(hash)
hash.transform_values {|value|
if [String, TrueClass, FalseClass, Integer, NilClass].any? {|c| value.is_a? c }
@ -121,7 +123,8 @@ shared_examples "a JSON Entity" do
describe "#to_json" do
it "#to_json output matches JSON schema" do
json = described_class.new(data).to_json
expect(json.to_json).to match_json_schema(:entity_schema)
errors = JSON::Validator.fully_validate("lib/diaspora_federation/schemas/federation_entities.json", json.to_json)
expect(errors).to be_empty
end
let(:to_json_output) { described_class.new(data).to_json.to_json }
@ -176,6 +179,7 @@ shared_examples "a relayable JSON entity" do
it "matches JSON schema with empty string signatures" do
json = described_class.new(data).to_json
json[:entity_data][:author_signature] = ""
expect(json.to_json).to match_json_schema(:entity_schema)
errors = JSON::Validator.fully_validate("lib/diaspora_federation/schemas/federation_entities.json", json.to_json)
expect(errors).to be_empty
end
end

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"

View file

@ -2,7 +2,7 @@
require "fileutils"
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
APP_ROOT = File.expand_path("..", __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
@ -13,13 +13,13 @@ FileUtils.chdir APP_ROOT do
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"
puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"
end

View file

@ -14,7 +14,6 @@ require "action_controller/railtie"
# require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
@ -25,7 +24,7 @@ require "diaspora_federation/rails"
module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.0
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#

View file

@ -1,6 +1,5 @@
# frozen_string_literal: true
# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile.

View file

@ -16,6 +16,9 @@ Rails.application.configure do
# Show full error reports.
config.consider_all_requests_local = true
# Enable server timing
config.server_timing = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
@ -47,16 +50,6 @@ Rails.application.configure do
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Set the logging destination(s)
config.log_to = %w[stdout file]
# Show the logging configuration on STDOUT
config.show_log_configuration = true
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
end

View file

@ -27,11 +27,11 @@ Rails.application.configure do
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = 'http://assets.example.com'
# config.asset_host = "http://assets.example.com"
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
@ -54,46 +54,19 @@ Rails.application.configure do
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Log disallowed deprecations.
config.active_support.disallowed_deprecation = :log
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Don't log any deprecations.
config.active_support.report_deprecations = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end

View file

@ -10,12 +10,13 @@ require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]

View file

@ -1,7 +0,0 @@
# frozen_string_literal: true
# Use net_http in test, that's better supported by webmock
unless Rails.env.test?
require "typhoeus/adapters/faraday"
Faraday.default_adapter = :typhoeus
end

View file

@ -2,7 +2,9 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application.config.filter_parameters += %i[
passw secret token _key crypt salt certificate otp ssn
]

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
mount DiasporaFederation::Engine => "/"
get "discovery" => "discovery#discovery"

View file

@ -24,10 +24,10 @@ group :test do
# test coverage
gem "simplecov", "0.21.2", require: false
gem "simplecov-rcov", "0.2.3", require: false
gem "simplecov-rcov", "0.3.1", require: false
# test helpers
gem "json-schema-rspec", "0.0.4"
gem "json-schema", "~> 3.0"
gem "rspec-collection_matchers", "~> 1.2.0"
gem "rspec-json_expectations", "~> 2.1"
gem "webmock", "~> 3.0"
@ -37,5 +37,5 @@ group :development, :test do
gem "rake"
# unit tests
gem "rspec", "~> 3.10.0"
gem "rspec", "~> 3.11.0"
end

View file

@ -2,15 +2,15 @@ PATH
remote: ../..
specs:
diaspora_federation (0.3.0)
faraday (~> 1.0)
faraday_middleware (~> 1.0)
faraday (>= 1.0, < 3)
faraday-follow_redirects (~> 0.3)
nokogiri (~> 1.6, >= 1.6.8)
typhoeus (~> 1.0)
valid (~> 1.0)
diaspora_federation-json_schema (0.3.0)
diaspora_federation-test (0.3.0)
diaspora_federation (= 0.3.0)
fabrication (~> 2.16)
fabrication (~> 2.29)
uuid (~> 2.3, >= 2.3.8)
GEM
@ -20,71 +20,50 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
crack (0.4.5)
rexml
diff-lcs (1.4.4)
diff-lcs (1.5.0)
docile (1.4.0)
ethon (0.15.0)
ffi (>= 1.15.0)
fabrication (2.22.0)
faraday (1.8.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
fabrication (2.29.0)
faraday (2.3.0)
faraday-net_http (~> 2.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday_middleware (1.2.0)
faraday (~> 1.0)
ffi (1.15.4)
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (2.0.3)
ffi (1.15.5)
fuubar (2.5.1)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
hashdiff (1.0.1)
json-schema (2.8.1)
addressable (>= 2.4)
json-schema-rspec (0.0.4)
json-schema (~> 2.5)
rspec
json-schema (3.0.0)
addressable (>= 2.8)
macaddr (1.7.2)
systemu (~> 2.6.5)
mini_portile2 (2.8.0)
multipart-post (2.1.1)
nokogiri (1.13.3)
mini_portile2 (~> 2.8.0)
nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
nyan-cat-formatter (0.12.0)
rspec (>= 2.99, >= 2.14.2, < 4)
public_suffix (4.0.6)
public_suffix (4.0.7)
racc (1.6.0)
rake (13.0.6)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-collection_matchers (1.2.0)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (~> 3.11.0)
rspec-json_expectations (2.2.0)
rspec-mocks (3.10.2)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
@ -92,9 +71,9 @@ GEM
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-rcov (0.2.3)
simplecov-rcov (0.3.1)
simplecov (>= 0.4.1)
simplecov_json_formatter (0.1.3)
simplecov_json_formatter (0.1.4)
systemu (2.6.5)
typhoeus (1.4.0)
ethon (>= 0.9.0)
@ -114,14 +93,14 @@ DEPENDENCIES
diaspora_federation-json_schema!
diaspora_federation-test!
fuubar (= 2.5.1)
json-schema-rspec (= 0.0.4)
json-schema (~> 3.0)
nyan-cat-formatter
rake
rspec (~> 3.10.0)
rspec (~> 3.11.0)
rspec-collection_matchers (~> 1.2.0)
rspec-json_expectations (~> 2.1)
simplecov (= 0.21.2)
simplecov-rcov (= 0.2.3)
simplecov-rcov (= 0.3.1)
webmock (~> 3.0)
BUNDLED WITH