Sha256: f8abd74680b61f3c378cae1d3990c5d114b6ee68507821bcd9b2678fec4760df

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# encoding: UTF-8

require "test_helper"

describe Vines::Stream::Server::Outbound::AuthDialbackResult do
  before do
    @stream = MiniTest::Mock.new
    @state = Vines::Stream::Server::Outbound::AuthDialbackResult.new(@stream)
  end

  def test_invalid_stanza
    EM.run {
      node = node("<message/>")
      assert_raises(Vines::StreamErrors::NotAuthorized) { @state.node(node) }
      assert @stream.verify
      EM.stop
    }
  end

  def test_invalid_result
    EM.run {
      node = node(
        %(<db:result xmlns:db="#{Vines::NAMESPACES[:legacy_dialback]}" ) +
        %(from="remote.host" to="local.host" type="invalid"/>)
      )
      @stream.expect(:close_connection, nil)
      @state.node(node)
      assert @stream.verify
      EM.stop
    }
  end

  def test_valid_result
    EM.run {
      node = node(
        %(<db:result xmlns:db="#{Vines::NAMESPACES[:legacy_dialback]}" ) +
        %(from="remote.host" to="local.host" type="valid"/>)
      )
      @stream.expect(:advance, nil, [Vines::Stream::Server::Ready])
      @stream.expect(:notify_connected, nil)
      @state.node(node)
      assert @stream.verify
      EM.stop
    }
  end

  private

  def node(xml)
    Nokogiri::XML(xml).root
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
diaspora-vines-0.2.0.develop.4 test/stream/server/outbound/auth_dialback_result_test.rb
diaspora-vines-0.2.0.develop.3 test/stream/server/outbound/auth_dialback_result_test.rb