~singpolyma/sgx-jmp

ref: 497b442bba246370bd5b724b5c2fa547ceb61ce6 sgx-jmp/test/test_proxied_jid.rb -rw-r--r-- 962 bytes
497b442bChristopher Vollick Customer Info 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require "test_helper"
require "proxied_jid"

class ProxiedJIDTest < Minitest::Test
	def test_unproxied
		jid = ProxiedJID.new(Blather::JID.new("test\\40example.com@example.net"))
		assert_equal "test@example.com", jid.unproxied.to_s
	end

	def test_proxied
		jid = ProxiedJID.proxy(Blather::JID.new("test@example.com"))
		assert_equal "test\\40example.com@example.net", jid.to_s
	end

	def test_escape
		jid = ProxiedJID.proxy(Blather::JID.new("test \"&'/:<>", "example.com"))
		assert_equal(
			"test\\20\\22\\26\\27\\2f\\3a\\3c\\3e\\40example.com@example.net",
			jid.to_s
		)
	end

	def test_backlash_necessary
		jid = ProxiedJID.proxy(Blather::JID.new("moop\\27@example.com"))
		assert_equal "moop\\5c27\\40example.com@example.net", jid.to_s
	end

	def test_backslash_unnecessary
		jid = ProxiedJID.proxy(Blather::JID.new("moop\\things@example.com"))
		assert_equal "moop\\things\\40example.com@example.net", jid.to_s
	end
end