getting_started_controller_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe GettingStartedController do
  4. describe '.validate_uri' do
  5. it 'false for nil' do
  6. expect(described_class.validate_uri(nil)).to be_falsey
  7. end
  8. it 'false for empty' do
  9. expect(described_class.validate_uri('')).to be_falsey
  10. end
  11. it 'false for non-http(s)' do
  12. expect(described_class.validate_uri('a://example.org')).to be_falsey
  13. end
  14. it 'false for gibberish uri' do
  15. expect(described_class.validate_uri('http:///a')).to be_falsey
  16. end
  17. it 'http and fqdn for http' do
  18. expect(described_class.validate_uri('http://example.org')).to eq({ scheme: 'http', fqdn: 'example.org' })
  19. end
  20. it 'https and fqdn for https' do
  21. expect(described_class.validate_uri('https://example.org')).to eq({ scheme: 'https', fqdn: 'example.org' })
  22. end
  23. it 'http and fqdn for http on default port' do
  24. expect(described_class.validate_uri('http://example.org:80')).to eq({ scheme: 'http', fqdn: 'example.org' })
  25. end
  26. it 'https and fqdn for https on default port' do
  27. expect(described_class.validate_uri('https://example.org:443')).to eq({ scheme: 'https', fqdn: 'example.org' })
  28. end
  29. it 'http and fqdn with port for http on custom port' do
  30. expect(described_class.validate_uri('http://example.org:443')).to eq({ scheme: 'http', fqdn: 'example.org:443' })
  31. end
  32. it 'https and fqdn with port for https on custom port' do
  33. expect(described_class.validate_uri('https://example.org:80')).to eq({ scheme: 'https', fqdn: 'example.org:80' })
  34. end
  35. end
  36. end