node_info_spec.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'The well-known node-info endpoints' do
  4. describe 'The /.well-known/node-info endpoint' do
  5. it 'returns JSON document pointing to node info' do
  6. get '/.well-known/nodeinfo'
  7. expect(response)
  8. .to have_http_status(200)
  9. .and have_attributes(
  10. media_type: 'application/json'
  11. )
  12. expect(response.parsed_body).to include(
  13. links: be_an(Array).and(
  14. contain_exactly(
  15. include(
  16. rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0',
  17. href: include('nodeinfo/2.0')
  18. )
  19. )
  20. )
  21. )
  22. end
  23. end
  24. describe 'The /nodeinfo/2.0 endpoint' do
  25. it 'returns JSON document with node info properties' do
  26. get '/nodeinfo/2.0'
  27. expect(response)
  28. .to have_http_status(200)
  29. .and have_attributes(
  30. media_type: 'application/json'
  31. )
  32. expect(non_matching_hash)
  33. .to_not match_json_schema('nodeinfo_2.0')
  34. expect(response.parsed_body)
  35. .to match_json_schema('nodeinfo_2.0')
  36. .and include(
  37. version: '2.0',
  38. usage: be_a(Hash),
  39. software: be_a(Hash),
  40. protocols: be_a(Array)
  41. )
  42. end
  43. private
  44. def non_matching_hash
  45. { 'foo' => 0 }
  46. end
  47. end
  48. end