You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xmpp_spec.rb 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. describe CryptCheck::Tls::Xmpp do
  2. def server(*args, **kargs, &block)
  3. kargs[:plain_process] = proc do |socket|
  4. socket.gets
  5. socket.puts "<?xml version='1.0'?><stream:stream xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='localhost' id='' xml:lang='en' xmlns='jabber:server'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls><dialback xmlns='urn:xmpp:features:dialback'/></stream:features>"
  6. socket.gets
  7. socket.puts "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' />"
  8. true
  9. end unless kargs.include? :plain_process
  10. starttls_serv *args, **kargs, &block
  11. end
  12. def plain_server(*args, **kargs, &block)
  13. kargs[:plain_process] = proc do |socket|
  14. socket.gets
  15. socket.puts "<?xml version='1.0'?><stream:stream xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='localhost' id='' xml:lang='en' xmlns='jabber:server'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls><dialback xmlns='urn:xmpp:features:dialback'/></stream:features>"
  16. socket.gets
  17. socket.puts "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' />"
  18. false
  19. end unless kargs.include? :plain_process
  20. starttls_serv *args, **kargs, &block
  21. end
  22. def analyze(*args)
  23. CryptCheck::Tls::Xmpp.analyze *args, type: :s2s
  24. end
  25. # include_examples :analysis do
  26. # it 'return error on XMPP error' do
  27. # plain_process = proc do |socket|
  28. # socket.gets
  29. # socket.puts "<?xml version='1.0'?><stream:stream xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='localhost' id='' xml:lang='en' xmlns='jabber:server'><stream:error><invalid-namespace xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>"
  30. # false
  31. # end
  32. #
  33. # grades = server host: '127.0.0.1', plain_process: plain_process do
  34. # analyze '127.0.0.1', 5000
  35. # end
  36. #
  37. # expect_grade_error grades, '127.0.0.1', '127.0.0.1', 5000,
  38. # '<invalid-namespace xmlns="urn:ietf:params:xml:ns:xmpp-streams"/>'
  39. # end
  40. # end
  41. #
  42. # describe '#required?' do
  43. # it 'has TLS not required' do
  44. # grades = server host: '127.0.0.1' do
  45. # analyze '127.0.0.1', 5000
  46. # end
  47. #
  48. # _, server = expect_grade grades, '127.0.0.1', '127.0.0.1', 5000, :ipv4
  49. # expect(server.required?).to be false
  50. # end
  51. #
  52. # it 'has TLS required' do
  53. # plain_process = proc do |socket|
  54. # socket.gets
  55. # socket.puts "<?xml version='1.0'?><stream:stream xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='localhost' id='' xml:lang='en' xmlns='jabber:server'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls><dialback xmlns='urn:xmpp:features:dialback'/></stream:features>"
  56. # socket.gets
  57. # socket.puts "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' />"
  58. # true
  59. # end
  60. #
  61. # grades = server host: '127.0.0.1', plain_process: plain_process do
  62. # analyze '127.0.0.1', 5000
  63. # end
  64. #
  65. # _, server = expect_grade grades, '127.0.0.1', '127.0.0.1', 5000, :ipv4
  66. # expect(server.required?).to be true
  67. # end
  68. # end
  69. end