We can have indented heredoc now \o/
This commit is contained in:
parent
1dfe57ea7e
commit
1570fff040
39 changed files with 1452 additions and 1460 deletions
|
|
@ -199,11 +199,3 @@ Style/DateTime:
|
|||
Exclude:
|
||||
- "lib/diaspora_federation/discovery/xrd_document.rb"
|
||||
- "spec/lib/diaspora_federation/discovery/xrd_document_spec.rb"
|
||||
|
||||
### backward compatibility
|
||||
|
||||
# only with ruby >= 2.3
|
||||
Layout/IndentHeredoc:
|
||||
Enabled: false
|
||||
Layout/ClosingHeredocIndentation:
|
||||
Enabled: false
|
||||
|
|
|
|||
|
|
@ -2,23 +2,23 @@
|
|||
|
||||
module DiasporaFederation
|
||||
describe Entities::Relayable do
|
||||
let(:author_serialized_key) { <<-KEY }
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh
|
||||
btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr
|
||||
yOVMQ4qCh1fKOMPX/LCvPzH+K7f8Q92zCuSvKSofg6zpg1zxGahpmxwqFQIDAQAB
|
||||
AoGBAKEXD2la/XF7FsTuwvLrsMNBgl40Ov+9/7u9oo3UZSmYp50mb0TXB4beZz7x
|
||||
Qt2wHRiJdnJRBUyvZ00C2EaTRJyFJA8p5J2qzHSjGpbPGyRCZUB6r6y+9vbM4ouj
|
||||
m5Vo47TQ7ob2D835BHJGR8dWM1zeAwWc6uLhNIu+/5lHQ90BAkEA6aVQFSXNYjmO
|
||||
fo6Oro+2nDaoa4jJ9qO1S23P2HF9N2f7CHDB4WKTdYnZpXs7ZPbnMEz62LeSC1MZ
|
||||
QOKGYkMuDQJBAMJEZWvfWtp+Zwm+IF1xGbNPzGrvHGJarE/QGUGYs7BR7tHFlepR
|
||||
aV3g56eGWfCWk8oWZRbjC2eQ2we96CU4cikCQQCqp3BCwgWthNSrY3yby6RZnSKO
|
||||
yK6bUx+MJHz3Xo1S9sPIenNiKBoEc9dgow3SxPQ/tzpRKGOnmd6MIeh9xQvRAkAV
|
||||
6WEHKco1msxEbQ15fKhJcVa9OPsanN+SoQY4P+EEojktr/uY0lXwIM4AN0ctu84v
|
||||
nRcJ3dILfGs4FFN630MBAkEA3zMOyNTeNdHrVhZc5b0qw2T6FUJGieDpOWLsff4w
|
||||
84yW10oS2CCmqEhbfh4Wu22amglytrATwD9hDzsTNAt8Mg==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
KEY
|
||||
let(:author_serialized_key) { <<~KEY }
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh
|
||||
btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr
|
||||
yOVMQ4qCh1fKOMPX/LCvPzH+K7f8Q92zCuSvKSofg6zpg1zxGahpmxwqFQIDAQAB
|
||||
AoGBAKEXD2la/XF7FsTuwvLrsMNBgl40Ov+9/7u9oo3UZSmYp50mb0TXB4beZz7x
|
||||
Qt2wHRiJdnJRBUyvZ00C2EaTRJyFJA8p5J2qzHSjGpbPGyRCZUB6r6y+9vbM4ouj
|
||||
m5Vo47TQ7ob2D835BHJGR8dWM1zeAwWc6uLhNIu+/5lHQ90BAkEA6aVQFSXNYjmO
|
||||
fo6Oro+2nDaoa4jJ9qO1S23P2HF9N2f7CHDB4WKTdYnZpXs7ZPbnMEz62LeSC1MZ
|
||||
QOKGYkMuDQJBAMJEZWvfWtp+Zwm+IF1xGbNPzGrvHGJarE/QGUGYs7BR7tHFlepR
|
||||
aV3g56eGWfCWk8oWZRbjC2eQ2we96CU4cikCQQCqp3BCwgWthNSrY3yby6RZnSKO
|
||||
yK6bUx+MJHz3Xo1S9sPIenNiKBoEc9dgow3SxPQ/tzpRKGOnmd6MIeh9xQvRAkAV
|
||||
6WEHKco1msxEbQ15fKhJcVa9OPsanN+SoQY4P+EEojktr/uY0lXwIM4AN0ctu84v
|
||||
nRcJ3dILfGs4FFN630MBAkEA3zMOyNTeNdHrVhZc5b0qw2T6FUJGieDpOWLsff4w
|
||||
84yW10oS2CCmqEhbfh4Wu22amglytrATwD9hDzsTNAt8Mg==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
KEY
|
||||
let(:author_key) { OpenSSL::PKey::RSA.new(author_serialized_key) }
|
||||
# -----BEGIN PUBLIC KEY-----
|
||||
# MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxTbMp+M5sCUDVi9k1wMxedSwy
|
||||
|
|
@ -27,23 +27,23 @@ KEY
|
|||
# g6zpg1zxGahpmxwqFQIDAQAB
|
||||
# -----END PUBLIC KEY-----
|
||||
|
||||
let(:parent_serialized_key) { <<-KEY }
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/
|
||||
F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx
|
||||
R7bygTbiCet4FAiyMjxOX3Oei/DedUNps1RAP1bu+80iibze/Kk9BgMm0QIDAQAB
|
||||
AoGAMHvikRCCaOl8SvnteBWzrLtsNAnJez9/KG0JcNdhLl4kxXWgHS0JW1wC4t4A
|
||||
jj2E6ZzCet6C1+Ebv3lc/jJdV3pCK3wgX0YAt/oBW5kcuvpLHLSWusWHnHkYU+qO
|
||||
4SdC3bRhdLV9o3u/oCWzmdeKTdqIyNd2yAbb3W1TsD4EsQECQQD6w+vWVKhWbVOj
|
||||
Ky3ZkLCxPcWNUt+7OIzDA1OLKhdhe44hIoRMfDT6iLK3sJTSjgOv0OFTfsdOqh5y
|
||||
ZqYp/CTpAkEA8CQFKkAYt4qG1lKMPsU/Tme0/Z24VozDRnyw7r663f0De+25kXGY
|
||||
PSBiOHYcAE6poYQEtR/leLTSaG3YZm7hqQJBAOLAWLg1Uwbb0v4/pDUQlgWfQsy4
|
||||
/KAx0W7hyiCTzhKTBAFIUfNLeSh2hYx+ewQt8H2B1s6GXDjwsZlm4qgiXUkCQQC9
|
||||
B12ZeIL8V2r0Yl5LOvEuQqxRx0lHt94vKhAMns5x16xabTLZrlVsKIWodDBufX1B
|
||||
yq359XWooo3N7kmduEKhAkEAppzKLuVtX1XPL4VZBex/M2ewngjkSg964BvxIBwv
|
||||
bFzeSqlMpnbEoOJ9hhx6CsP6Y7V19DRRXi0XgwcAjHLz8g==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
KEY
|
||||
let(:parent_serialized_key) { <<~KEY }
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/
|
||||
F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx
|
||||
R7bygTbiCet4FAiyMjxOX3Oei/DedUNps1RAP1bu+80iibze/Kk9BgMm0QIDAQAB
|
||||
AoGAMHvikRCCaOl8SvnteBWzrLtsNAnJez9/KG0JcNdhLl4kxXWgHS0JW1wC4t4A
|
||||
jj2E6ZzCet6C1+Ebv3lc/jJdV3pCK3wgX0YAt/oBW5kcuvpLHLSWusWHnHkYU+qO
|
||||
4SdC3bRhdLV9o3u/oCWzmdeKTdqIyNd2yAbb3W1TsD4EsQECQQD6w+vWVKhWbVOj
|
||||
Ky3ZkLCxPcWNUt+7OIzDA1OLKhdhe44hIoRMfDT6iLK3sJTSjgOv0OFTfsdOqh5y
|
||||
ZqYp/CTpAkEA8CQFKkAYt4qG1lKMPsU/Tme0/Z24VozDRnyw7r663f0De+25kXGY
|
||||
PSBiOHYcAE6poYQEtR/leLTSaG3YZm7hqQJBAOLAWLg1Uwbb0v4/pDUQlgWfQsy4
|
||||
/KAx0W7hyiCTzhKTBAFIUfNLeSh2hYx+ewQt8H2B1s6GXDjwsZlm4qgiXUkCQQC9
|
||||
B12ZeIL8V2r0Yl5LOvEuQqxRx0lHt94vKhAMns5x16xabTLZrlVsKIWodDBufX1B
|
||||
yq359XWooo3N7kmduEKhAkEAppzKLuVtX1XPL4VZBex/M2ewngjkSg964BvxIBwv
|
||||
bFzeSqlMpnbEoOJ9hhx6CsP6Y7V19DRRXi0XgwcAjHLz8g==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
KEY
|
||||
let(:parent_key) { OpenSSL::PKey::RSA.new(parent_serialized_key) }
|
||||
# -----BEGIN PUBLIC KEY-----
|
||||
# MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrOvW1UArKoUOg54XWXcTD3jU0
|
||||
|
|
@ -65,116 +65,116 @@ KEY
|
|||
)
|
||||
}
|
||||
|
||||
let(:legacy_format_comment_xml_alice) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<author_signature>XU5X1uqTh8SY6JMG9uhEVR5Rg7FURV6lpRwl/HYOu6DJ3Hd9tpA2aSFFibUxxsMgJXKNrrc5SykrrEdTiQoEei+j0QqZf3B5R7r84qgK7M46KazwIpqRPwVl2MdA/0DdQyYJLA/oavNj1nwll9vtR87M7e/C94qG6P+iQTMBQzo=</author_signature>
|
||||
<parent_author_signature/>
|
||||
<text>this is a very informative comment</text>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:new_format_comment_xml_alice) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author_signature>SQbLeqsEpFmSl74G1fFJXKQcsq6jp5B2ZjmfEOF/LbBccYP2oZEyEqOq18K3Fa71OYTp6Nddb38hCmHWWHvnGUltGfxKBnQ0WHafJUi40VM4VmeRoU8cac6m+1hslwe5SNmK6oh47EV3mRCXlgGGjLIrw7iEwjKL2g9x1gkNp2s=</author_signature>
|
||||
<parent_author_signature/>
|
||||
</comment>
|
||||
XML
|
||||
let(:new_data_comment_xml_alice) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<new_data>foobar</new_data>
|
||||
<author_signature>SFYXSvCX/DhTFiOUALp2Nf1kfNkGKXrnoBPikAyhaIogGydVBm+8tIlu1U/vsnpyKO3yfC3JReJ00/UBd4J16VO1IxStntq8NUqbSv4me5A/6kdK9Xg6eYbXrqQGm8fUQ5Xuh2UzeB71p7SVySXX3OZHVe0dvHCxH/lsfSDpEjc=</author_signature>
|
||||
<parent_author_signature/>
|
||||
</comment>
|
||||
XML
|
||||
let(:legacy_format_comment_xml_alice) { <<~XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<author_signature>XU5X1uqTh8SY6JMG9uhEVR5Rg7FURV6lpRwl/HYOu6DJ3Hd9tpA2aSFFibUxxsMgJXKNrrc5SykrrEdTiQoEei+j0QqZf3B5R7r84qgK7M46KazwIpqRPwVl2MdA/0DdQyYJLA/oavNj1nwll9vtR87M7e/C94qG6P+iQTMBQzo=</author_signature>
|
||||
<parent_author_signature/>
|
||||
<text>this is a very informative comment</text>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:new_format_comment_xml_alice) { <<~XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author_signature>SQbLeqsEpFmSl74G1fFJXKQcsq6jp5B2ZjmfEOF/LbBccYP2oZEyEqOq18K3Fa71OYTp6Nddb38hCmHWWHvnGUltGfxKBnQ0WHafJUi40VM4VmeRoU8cac6m+1hslwe5SNmK6oh47EV3mRCXlgGGjLIrw7iEwjKL2g9x1gkNp2s=</author_signature>
|
||||
<parent_author_signature/>
|
||||
</comment>
|
||||
XML
|
||||
let(:new_data_comment_xml_alice) { <<~XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<new_data>foobar</new_data>
|
||||
<author_signature>SFYXSvCX/DhTFiOUALp2Nf1kfNkGKXrnoBPikAyhaIogGydVBm+8tIlu1U/vsnpyKO3yfC3JReJ00/UBd4J16VO1IxStntq8NUqbSv4me5A/6kdK9Xg6eYbXrqQGm8fUQ5Xuh2UzeB71p7SVySXX3OZHVe0dvHCxH/lsfSDpEjc=</author_signature>
|
||||
<parent_author_signature/>
|
||||
</comment>
|
||||
XML
|
||||
|
||||
let(:legacy_format_comment_xml_bob) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
<author_signature>XU5X1uqTh8SY6JMG9uhEVR5Rg7FURV6lpRwl/HYOu6DJ3Hd9tpA2aSFFibUxxsMgJXKNrrc5SykrrEdTiQoEei+j0QqZf3B5R7r84qgK7M46KazwIpqRPwVl2MdA/0DdQyYJLA/oavNj1nwll9vtR87M7e/C94qG6P+iQTMBQzo=</author_signature>
|
||||
<parent_author_signature>QqWSdwpb+/dcJUxuKKVe7aiz1NivXzlIdWZ71xyrxnhFxFYd+7EIittyTcp1cVehjg96pwDbn++P/rWyCffqenWu025DHvUfSmQkC93Z0dX6r3OIUlZqwEggtOdbunybiE++F3BVsGt5wC4YbAESB5ZFuhFVhBXh1X+EaZ/qoKo=</parent_author_signature>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:legacy_order_new_format_comment_xml_bob) { <<-XML }
|
||||
<comment>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author>alice@pod-a.org</author>
|
||||
<author_signature>XU5X1uqTh8SY6JMG9uhEVR5Rg7FURV6lpRwl/HYOu6DJ3Hd9tpA2aSFFibUxxsMgJXKNrrc5SykrrEdTiQoEei+j0QqZf3B5R7r84qgK7M46KazwIpqRPwVl2MdA/0DdQyYJLA/oavNj1nwll9vtR87M7e/C94qG6P+iQTMBQzo=</author_signature>
|
||||
<parent_author_signature>QqWSdwpb+/dcJUxuKKVe7aiz1NivXzlIdWZ71xyrxnhFxFYd+7EIittyTcp1cVehjg96pwDbn++P/rWyCffqenWu025DHvUfSmQkC93Z0dX6r3OIUlZqwEggtOdbunybiE++F3BVsGt5wC4YbAESB5ZFuhFVhBXh1X+EaZ/qoKo=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
let(:new_order_legacy_format_comment_xml_bob) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author_signature>SQbLeqsEpFmSl74G1fFJXKQcsq6jp5B2ZjmfEOF/LbBccYP2oZEyEqOq18K3Fa71OYTp6Nddb38hCmHWWHvnGUltGfxKBnQ0WHafJUi40VM4VmeRoU8cac6m+1hslwe5SNmK6oh47EV3mRCXlgGGjLIrw7iEwjKL2g9x1gkNp2s=</author_signature>
|
||||
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:new_format_comment_xml_bob) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author_signature>SQbLeqsEpFmSl74G1fFJXKQcsq6jp5B2ZjmfEOF/LbBccYP2oZEyEqOq18K3Fa71OYTp6Nddb38hCmHWWHvnGUltGfxKBnQ0WHafJUi40VM4VmeRoU8cac6m+1hslwe5SNmK6oh47EV3mRCXlgGGjLIrw7iEwjKL2g9x1gkNp2s=</author_signature>
|
||||
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
let(:legacy_format_new_data_comment_xml_bob) { <<-XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<new_data>foobar</new_data>
|
||||
<author_signature>SFYXSvCX/DhTFiOUALp2Nf1kfNkGKXrnoBPikAyhaIogGydVBm+8tIlu1U/vsnpyKO3yfC3JReJ00/UBd4J16VO1IxStntq8NUqbSv4me5A/6kdK9Xg6eYbXrqQGm8fUQ5Xuh2UzeB71p7SVySXX3OZHVe0dvHCxH/lsfSDpEjc=</author_signature>
|
||||
<parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:new_data_comment_xml_bob) { <<-XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<new_data>foobar</new_data>
|
||||
<author_signature>SFYXSvCX/DhTFiOUALp2Nf1kfNkGKXrnoBPikAyhaIogGydVBm+8tIlu1U/vsnpyKO3yfC3JReJ00/UBd4J16VO1IxStntq8NUqbSv4me5A/6kdK9Xg6eYbXrqQGm8fUQ5Xuh2UzeB71p7SVySXX3OZHVe0dvHCxH/lsfSDpEjc=</author_signature>
|
||||
<parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
let(:legacy_format_comment_xml_bob) { <<~XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
<author_signature>XU5X1uqTh8SY6JMG9uhEVR5Rg7FURV6lpRwl/HYOu6DJ3Hd9tpA2aSFFibUxxsMgJXKNrrc5SykrrEdTiQoEei+j0QqZf3B5R7r84qgK7M46KazwIpqRPwVl2MdA/0DdQyYJLA/oavNj1nwll9vtR87M7e/C94qG6P+iQTMBQzo=</author_signature>
|
||||
<parent_author_signature>QqWSdwpb+/dcJUxuKKVe7aiz1NivXzlIdWZ71xyrxnhFxFYd+7EIittyTcp1cVehjg96pwDbn++P/rWyCffqenWu025DHvUfSmQkC93Z0dX6r3OIUlZqwEggtOdbunybiE++F3BVsGt5wC4YbAESB5ZFuhFVhBXh1X+EaZ/qoKo=</parent_author_signature>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:legacy_order_new_format_comment_xml_bob) { <<~XML }
|
||||
<comment>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author>alice@pod-a.org</author>
|
||||
<author_signature>XU5X1uqTh8SY6JMG9uhEVR5Rg7FURV6lpRwl/HYOu6DJ3Hd9tpA2aSFFibUxxsMgJXKNrrc5SykrrEdTiQoEei+j0QqZf3B5R7r84qgK7M46KazwIpqRPwVl2MdA/0DdQyYJLA/oavNj1nwll9vtR87M7e/C94qG6P+iQTMBQzo=</author_signature>
|
||||
<parent_author_signature>QqWSdwpb+/dcJUxuKKVe7aiz1NivXzlIdWZ71xyrxnhFxFYd+7EIittyTcp1cVehjg96pwDbn++P/rWyCffqenWu025DHvUfSmQkC93Z0dX6r3OIUlZqwEggtOdbunybiE++F3BVsGt5wC4YbAESB5ZFuhFVhBXh1X+EaZ/qoKo=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
let(:new_order_legacy_format_comment_xml_bob) { <<~XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author_signature>SQbLeqsEpFmSl74G1fFJXKQcsq6jp5B2ZjmfEOF/LbBccYP2oZEyEqOq18K3Fa71OYTp6Nddb38hCmHWWHvnGUltGfxKBnQ0WHafJUi40VM4VmeRoU8cac6m+1hslwe5SNmK6oh47EV3mRCXlgGGjLIrw7iEwjKL2g9x1gkNp2s=</author_signature>
|
||||
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:new_format_comment_xml_bob) { <<~XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<author_signature>SQbLeqsEpFmSl74G1fFJXKQcsq6jp5B2ZjmfEOF/LbBccYP2oZEyEqOq18K3Fa71OYTp6Nddb38hCmHWWHvnGUltGfxKBnQ0WHafJUi40VM4VmeRoU8cac6m+1hslwe5SNmK6oh47EV3mRCXlgGGjLIrw7iEwjKL2g9x1gkNp2s=</author_signature>
|
||||
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
let(:legacy_format_new_data_comment_xml_bob) { <<~XML }
|
||||
<XML>
|
||||
<post>
|
||||
<comment>
|
||||
<diaspora_handle>alice@pod-a.org</diaspora_handle>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<new_data>foobar</new_data>
|
||||
<author_signature>SFYXSvCX/DhTFiOUALp2Nf1kfNkGKXrnoBPikAyhaIogGydVBm+8tIlu1U/vsnpyKO3yfC3JReJ00/UBd4J16VO1IxStntq8NUqbSv4me5A/6kdK9Xg6eYbXrqQGm8fUQ5Xuh2UzeB71p7SVySXX3OZHVe0dvHCxH/lsfSDpEjc=</author_signature>
|
||||
<parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature>
|
||||
</comment>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:new_data_comment_xml_bob) { <<~XML }
|
||||
<comment>
|
||||
<author>alice@pod-a.org</author>
|
||||
<guid>e21589b0b41101333b870f77ba60fa73</guid>
|
||||
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
|
||||
<text>this is a very informative comment</text>
|
||||
<new_data>foobar</new_data>
|
||||
<author_signature>SFYXSvCX/DhTFiOUALp2Nf1kfNkGKXrnoBPikAyhaIogGydVBm+8tIlu1U/vsnpyKO3yfC3JReJ00/UBd4J16VO1IxStntq8NUqbSv4me5A/6kdK9Xg6eYbXrqQGm8fUQ5Xuh2UzeB71p7SVySXX3OZHVe0dvHCxH/lsfSDpEjc=</author_signature>
|
||||
<parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
|
||||
# this was used to create the XMLs above
|
||||
context "test-data creation" do
|
||||
|
|
|
|||
|
|
@ -23,90 +23,90 @@ module DiasporaFederation
|
|||
}
|
||||
}
|
||||
|
||||
let(:html) { <<-HTML }
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="UTF-8" />
|
||||
<title>#{person.full_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>#{person.full_name}</h1>
|
||||
<div id="content_inner" class="entity_profile vcard author">
|
||||
<h2>User profile</h2>
|
||||
<dl class="entity_uid">
|
||||
<dt>Uid</dt>
|
||||
<dd>
|
||||
<span class="uid">#{person.guid}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_nickname">
|
||||
<dt>Nickname</dt>
|
||||
<dd>
|
||||
<span class="nickname">#{person.nickname}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_full_name">
|
||||
<dt>Full_name</dt>
|
||||
<dd>
|
||||
<span class="fn">#{person.full_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_searchable">
|
||||
<dt>Searchable</dt>
|
||||
<dd>
|
||||
<span class="searchable">#{person.searchable}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_key">
|
||||
<dt>Key</dt>
|
||||
<dd>
|
||||
<pre class="key">#{person.serialized_public_key}</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_first_name">
|
||||
<dt>First_name</dt>
|
||||
<dd>
|
||||
<span class="given_name">#{person.first_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_family_name">
|
||||
<dt>Family_name</dt>
|
||||
<dd>
|
||||
<span class="family_name">#{person.last_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_url">
|
||||
<dt>Url</dt>
|
||||
<dd>
|
||||
<a id="pod_location" class="url" rel="me" href="#{person.url}">#{person.url}</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo">
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_medium">
|
||||
<dt>Photo_medium</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_small">
|
||||
<dt>Photo_small</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
let(:html) { <<~HTML }
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="UTF-8" />
|
||||
<title>#{person.full_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>#{person.full_name}</h1>
|
||||
<div id="content_inner" class="entity_profile vcard author">
|
||||
<h2>User profile</h2>
|
||||
<dl class="entity_uid">
|
||||
<dt>Uid</dt>
|
||||
<dd>
|
||||
<span class="uid">#{person.guid}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_nickname">
|
||||
<dt>Nickname</dt>
|
||||
<dd>
|
||||
<span class="nickname">#{person.nickname}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_full_name">
|
||||
<dt>Full_name</dt>
|
||||
<dd>
|
||||
<span class="fn">#{person.full_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_searchable">
|
||||
<dt>Searchable</dt>
|
||||
<dd>
|
||||
<span class="searchable">#{person.searchable}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_key">
|
||||
<dt>Key</dt>
|
||||
<dd>
|
||||
<pre class="key">#{person.serialized_public_key}</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_first_name">
|
||||
<dt>First_name</dt>
|
||||
<dd>
|
||||
<span class="given_name">#{person.first_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_family_name">
|
||||
<dt>Family_name</dt>
|
||||
<dd>
|
||||
<span class="family_name">#{person.last_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_url">
|
||||
<dt>Url</dt>
|
||||
<dd>
|
||||
<a id="pod_location" class="url" rel="me" href="#{person.url}">#{person.url}</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo">
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_medium">
|
||||
<dt>Photo_medium</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_small">
|
||||
<dt>Photo_small</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
let(:string) { "HCard:#{data[:guid]}" }
|
||||
|
||||
|
|
@ -136,78 +136,78 @@ HTML
|
|||
end
|
||||
|
||||
it "reads minimal hCard" do
|
||||
minimal_html = <<-HTML
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="UTF-8" />
|
||||
<title>#{person.full_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>#{person.full_name}</h1>
|
||||
<div id="content_inner" class="entity_profile vcard author">
|
||||
<h2>User profile</h2>
|
||||
<dl class="entity_uid">
|
||||
<dt>Uid</dt>
|
||||
<dd>
|
||||
<span class="uid">#{person.guid}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_full_name">
|
||||
<dt>Full_name</dt>
|
||||
<dd>
|
||||
<span class="fn">#{person.full_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_searchable">
|
||||
<dt>Searchable</dt>
|
||||
<dd>
|
||||
<span class="searchable">#{person.searchable}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_key">
|
||||
<dt>Key</dt>
|
||||
<dd>
|
||||
<pre class="key">#{person.serialized_public_key}</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_first_name">
|
||||
<dt>First_name</dt>
|
||||
<dd>
|
||||
<span class="given_name">#{person.first_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_family_name">
|
||||
<dt>Family_name</dt>
|
||||
<dd>
|
||||
<span class="family_name">#{person.last_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo">
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_medium">
|
||||
<dt>Photo_medium</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_small">
|
||||
<dt>Photo_small</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
minimal_html = <<~HTML
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta charset="UTF-8" />
|
||||
<title>#{person.full_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>#{person.full_name}</h1>
|
||||
<div id="content_inner" class="entity_profile vcard author">
|
||||
<h2>User profile</h2>
|
||||
<dl class="entity_uid">
|
||||
<dt>Uid</dt>
|
||||
<dd>
|
||||
<span class="uid">#{person.guid}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_full_name">
|
||||
<dt>Full_name</dt>
|
||||
<dd>
|
||||
<span class="fn">#{person.full_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_searchable">
|
||||
<dt>Searchable</dt>
|
||||
<dd>
|
||||
<span class="searchable">#{person.searchable}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_key">
|
||||
<dt>Key</dt>
|
||||
<dd>
|
||||
<pre class="key">#{person.serialized_public_key}</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_first_name">
|
||||
<dt>First_name</dt>
|
||||
<dd>
|
||||
<span class="given_name">#{person.first_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_family_name">
|
||||
<dt>Family_name</dt>
|
||||
<dd>
|
||||
<span class="family_name">#{person.last_name}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo">
|
||||
<dt>Photo</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="300" height="300" src="#{photo_large_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_medium">
|
||||
<dt>Photo_medium</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="100" height="100" src="#{photo_medium_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="entity_photo_small">
|
||||
<dt>Photo_small</dt>
|
||||
<dd>
|
||||
<img class="photo avatar" width="50" height="50" src="#{photo_small_url}" />
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
hcard = Discovery::HCard.from_html(minimal_html)
|
||||
expect(hcard.guid).to eq(person.guid)
|
||||
|
|
@ -261,11 +261,11 @@ HTML
|
|||
end
|
||||
|
||||
it "fails if the document is incomplete" do
|
||||
invalid_html = <<-HTML
|
||||
<div id="content">
|
||||
<span class="fn">#{person.full_name}</span>
|
||||
</div>
|
||||
HTML
|
||||
invalid_html = <<~HTML
|
||||
<div id="content">
|
||||
<span class="fn">#{person.full_name}</span>
|
||||
</div>
|
||||
HTML
|
||||
expect { Discovery::HCard.from_html(invalid_html) }.to raise_error Discovery::InvalidData
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
module DiasporaFederation
|
||||
describe Discovery::HostMeta do
|
||||
let(:base_url) { "https://pod.example.tld/" }
|
||||
let(:xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}.well-known/webfinger.xml?resource={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}.well-known/webfinger.xml?resource={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
it "must not create blank instances" do
|
||||
expect { Discovery::HostMeta.new }.to raise_error NoMethodError
|
||||
|
|
@ -42,56 +42,56 @@ XML
|
|||
end
|
||||
|
||||
it "also reads old-style XML" do
|
||||
historic_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
historic_xml = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
|
||||
<!-- Resource-specific Information -->
|
||||
<!-- Resource-specific Information -->
|
||||
|
||||
<Link rel="lrdd"
|
||||
type="application/xrd+xml"
|
||||
template="#{base_url}webfinger?q={uri}" />
|
||||
<Link rel="lrdd"
|
||||
type="application/xrd+xml"
|
||||
template="#{base_url}webfinger?q={uri}" />
|
||||
|
||||
</XRD>
|
||||
XML
|
||||
</XRD>
|
||||
XML
|
||||
hm = Discovery::HostMeta.from_xml(historic_xml)
|
||||
expect(hm.webfinger_template_url).to eq("#{base_url}webfinger?q={uri}")
|
||||
end
|
||||
|
||||
it "also reads friendica/redmatrix XML" do
|
||||
friendica_redmatrix_xml = <<-XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
||||
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||
friendica_redmatrix_xml = <<~XML
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
||||
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||
|
||||
<hm:Host>pod.example.tld</hm:Host>
|
||||
<hm:Host>pod.example.tld</hm:Host>
|
||||
|
||||
<Link rel='lrdd' template='#{base_url}xrd/?uri={uri}' />
|
||||
<Link rel="http://oexchange.org/spec/0.8/rel/resident-target" type="application/xrd+xml"
|
||||
href="https://pod.example.tld/oexchange/xrd" />
|
||||
<Link rel='lrdd' template='#{base_url}xrd/?uri={uri}' />
|
||||
<Link rel="http://oexchange.org/spec/0.8/rel/resident-target" type="application/xrd+xml"
|
||||
href="https://pod.example.tld/oexchange/xrd" />
|
||||
|
||||
</XRD>
|
||||
</XRD>
|
||||
XML
|
||||
hm = Discovery::HostMeta.from_xml(friendica_redmatrix_xml)
|
||||
expect(hm.webfinger_template_url).to eq("#{base_url}xrd/?uri={uri}")
|
||||
end
|
||||
|
||||
it "fails if the document does not contain a webfinger url" do
|
||||
invalid_xml = <<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
</XRD>
|
||||
XML
|
||||
invalid_xml = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
</XRD>
|
||||
XML
|
||||
expect { Discovery::HostMeta.from_xml(invalid_xml) }.to raise_error Discovery::InvalidData
|
||||
end
|
||||
|
||||
it "fails if the document contains a malformed webfinger url" do
|
||||
invalid_xml = <<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q="/>
|
||||
</XRD>
|
||||
XML
|
||||
invalid_xml = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q="/>
|
||||
</XRD>
|
||||
XML
|
||||
expect { Discovery::HostMeta.from_xml(invalid_xml) }.to raise_error Discovery::InvalidData
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,85 +18,85 @@ module DiasporaFederation
|
|||
}
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
<Alias>#{person.alias_url}</Alias>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}"/>
|
||||
<Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="#{person.profile_url}"/>
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="#{person.atom_url}"/>
|
||||
<Link rel="salmon" href="#{person.salmon_url}"/>
|
||||
<Link rel="http://ostatus.org/schema/1.0/subscribe" template="#{person.subscribe_url}"/>
|
||||
</XRD>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
<Alias>#{person.alias_url}</Alias>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}"/>
|
||||
<Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="#{person.profile_url}"/>
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="#{person.atom_url}"/>
|
||||
<Link rel="salmon" href="#{person.salmon_url}"/>
|
||||
<Link rel="http://ostatus.org/schema/1.0/subscribe" template="#{person.subscribe_url}"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
let(:minimal_xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}"/>
|
||||
</XRD>
|
||||
XML
|
||||
let(:minimal_xml) { <<~XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"subject": "#{acct}",
|
||||
"aliases": [
|
||||
"#{person.alias_url}"
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://microformats.org/profile/hcard",
|
||||
"type": "text/html",
|
||||
"href": "#{person.hcard_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://joindiaspora.com/seed_location",
|
||||
"type": "text/html",
|
||||
"href": "#{person.url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/profile-page",
|
||||
"type": "text/html",
|
||||
"href": "#{person.profile_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://schemas.google.com/g/2010#updates-from",
|
||||
"type": "application/atom+xml",
|
||||
"href": "#{person.atom_url}"
|
||||
},
|
||||
{
|
||||
"rel": "salmon",
|
||||
"href": "#{person.salmon_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template": "http://somehost:3000/people?q={uri}"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"subject": "#{acct}",
|
||||
"aliases": [
|
||||
"#{person.alias_url}"
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://microformats.org/profile/hcard",
|
||||
"type": "text/html",
|
||||
"href": "#{person.hcard_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://joindiaspora.com/seed_location",
|
||||
"type": "text/html",
|
||||
"href": "#{person.url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/profile-page",
|
||||
"type": "text/html",
|
||||
"href": "#{person.profile_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://schemas.google.com/g/2010#updates-from",
|
||||
"type": "application/atom+xml",
|
||||
"href": "#{person.atom_url}"
|
||||
},
|
||||
{
|
||||
"rel": "salmon",
|
||||
"href": "#{person.salmon_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://ostatus.org/schema/1.0/subscribe",
|
||||
"template": "http://somehost:3000/people?q={uri}"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:minimal_json) { <<-JSON }
|
||||
{
|
||||
"subject": "#{acct}",
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://microformats.org/profile/hcard",
|
||||
"type": "text/html",
|
||||
"href": "#{person.hcard_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://joindiaspora.com/seed_location",
|
||||
"type": "text/html",
|
||||
"href": "#{person.url}"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
let(:minimal_json) { <<~JSON }
|
||||
{
|
||||
"subject": "#{acct}",
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://microformats.org/profile/hcard",
|
||||
"type": "text/html",
|
||||
"href": "#{person.hcard_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://joindiaspora.com/seed_location",
|
||||
"type": "text/html",
|
||||
"href": "#{person.url}"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "WebFinger:#{data[:acct_uri]}" }
|
||||
|
||||
|
|
@ -132,20 +132,20 @@ JSON
|
|||
end
|
||||
|
||||
it "creates XML document with additional data" do
|
||||
xml_with_additional_data = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
<Alias>#{person.alias_url}</Alias>
|
||||
<Alias>#{person.profile_url}</Alias>
|
||||
<Property type="http://webfinger.example/ns/name">Bob Smith</Property>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}"/>
|
||||
<Link rel="http://portablecontacts.net/spec/1.0" href="https://pod.example.tld/poco/trouble"/>
|
||||
<Link rel="http://webfinger.net/rel/avatar" type="image/jpeg" href="http://localhost:3000/assets/user/default.png"/>
|
||||
<Link rel="http://openid.net/specs/connect/1.0/issuer" href="https://pod.example.tld/"/>
|
||||
</XRD>
|
||||
XML
|
||||
xml_with_additional_data = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>#{acct}</Subject>
|
||||
<Alias>#{person.alias_url}</Alias>
|
||||
<Alias>#{person.profile_url}</Alias>
|
||||
<Property type="http://webfinger.example/ns/name">Bob Smith</Property>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}"/>
|
||||
<Link rel="http://portablecontacts.net/spec/1.0" href="https://pod.example.tld/poco/trouble"/>
|
||||
<Link rel="http://webfinger.net/rel/avatar" type="image/jpeg" href="http://localhost:3000/assets/user/default.png"/>
|
||||
<Link rel="http://openid.net/specs/connect/1.0/issuer" href="https://pod.example.tld/"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
wf = Discovery::WebFinger.new(minimal_data, additional_data)
|
||||
expect(wf.to_xml).to eq(xml_with_additional_data)
|
||||
|
|
@ -164,43 +164,43 @@ XML
|
|||
end
|
||||
|
||||
it "creates JSON document with additional data" do
|
||||
json_with_additional_data = <<-JSON
|
||||
{
|
||||
"subject": "#{acct}",
|
||||
"aliases": [
|
||||
"#{person.alias_url}",
|
||||
"#{person.profile_url}"
|
||||
],
|
||||
"properties": {
|
||||
"http://webfinger.example/ns/name": "Bob Smith"
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://microformats.org/profile/hcard",
|
||||
"type": "text/html",
|
||||
"href": "#{person.hcard_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://joindiaspora.com/seed_location",
|
||||
"type": "text/html",
|
||||
"href": "#{person.url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://portablecontacts.net/spec/1.0",
|
||||
"href": "https://pod.example.tld/poco/trouble"
|
||||
},
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/avatar",
|
||||
"type": "image/jpeg",
|
||||
"href": "http://localhost:3000/assets/user/default.png"
|
||||
},
|
||||
{
|
||||
"rel": "http://openid.net/specs/connect/1.0/issuer",
|
||||
"href": "https://pod.example.tld/"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
json_with_additional_data = <<~JSON
|
||||
{
|
||||
"subject": "#{acct}",
|
||||
"aliases": [
|
||||
"#{person.alias_url}",
|
||||
"#{person.profile_url}"
|
||||
],
|
||||
"properties": {
|
||||
"http://webfinger.example/ns/name": "Bob Smith"
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://microformats.org/profile/hcard",
|
||||
"type": "text/html",
|
||||
"href": "#{person.hcard_url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://joindiaspora.com/seed_location",
|
||||
"type": "text/html",
|
||||
"href": "#{person.url}"
|
||||
},
|
||||
{
|
||||
"rel": "http://portablecontacts.net/spec/1.0",
|
||||
"href": "https://pod.example.tld/poco/trouble"
|
||||
},
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/avatar",
|
||||
"type": "image/jpeg",
|
||||
"href": "http://localhost:3000/assets/user/default.png"
|
||||
},
|
||||
{
|
||||
"rel": "http://openid.net/specs/connect/1.0/issuer",
|
||||
"href": "https://pod.example.tld/"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
wf = Discovery::WebFinger.new(minimal_data, additional_data)
|
||||
expect(JSON.pretty_generate(wf.to_json)).to eq(json_with_additional_data.strip)
|
||||
|
|
@ -251,50 +251,50 @@ JSON
|
|||
end
|
||||
|
||||
it "reads friendica XML (two aliases, first with acct)" do
|
||||
friendica_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
friendica_xml = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
|
||||
<Subject>#{acct}</Subject>
|
||||
<Alias>#{acct}</Alias>
|
||||
<Alias>#{person.alias_url}</Alias>
|
||||
<Subject>#{acct}</Subject>
|
||||
<Alias>#{acct}</Alias>
|
||||
<Alias>#{person.alias_url}</Alias>
|
||||
|
||||
<Link rel="http://purl.org/macgirvin/dfrn/1.0"
|
||||
href="#{person.profile_url}" />
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from"
|
||||
type="application/atom+xml"
|
||||
href="#{person.atom_url}" />
|
||||
<Link rel="http://webfinger.net/rel/profile-page"
|
||||
type="text/html"
|
||||
href="#{person.profile_url}" />
|
||||
<Link rel="http://microformats.org/profile/hcard"
|
||||
type="text/html"
|
||||
href="#{person.hcard_url}" />
|
||||
<Link rel="http://portablecontacts.net/spec/1.0"
|
||||
href="https://pod.example.tld/poco/trouble" />
|
||||
<Link rel="http://webfinger.net/rel/avatar"
|
||||
type="image/jpeg"
|
||||
href="http://localhost:3000/assets/user/default.png" />
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}" />
|
||||
<Link rel="http://joindiaspora.com/guid" type="text/html" href="#{person.guid}" />
|
||||
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}" />
|
||||
<Link rel="http://purl.org/macgirvin/dfrn/1.0"
|
||||
href="#{person.profile_url}" />
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from"
|
||||
type="application/atom+xml"
|
||||
href="#{person.atom_url}" />
|
||||
<Link rel="http://webfinger.net/rel/profile-page"
|
||||
type="text/html"
|
||||
href="#{person.profile_url}" />
|
||||
<Link rel="http://microformats.org/profile/hcard"
|
||||
type="text/html"
|
||||
href="#{person.hcard_url}" />
|
||||
<Link rel="http://portablecontacts.net/spec/1.0"
|
||||
href="https://pod.example.tld/poco/trouble" />
|
||||
<Link rel="http://webfinger.net/rel/avatar"
|
||||
type="image/jpeg"
|
||||
href="http://localhost:3000/assets/user/default.png" />
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}" />
|
||||
<Link rel="http://joindiaspora.com/guid" type="text/html" href="#{person.guid}" />
|
||||
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}" />
|
||||
|
||||
<Link rel="salmon"
|
||||
href="#{person.salmon_url}" />
|
||||
<Link rel="http://salmon-protocol.org/ns/salmon-replies"
|
||||
href="https://pod.example.tld/salmon/trouble" />
|
||||
<Link rel="http://salmon-protocol.org/ns/salmon-mention"
|
||||
href="https://pod.example.tld/salmon/trouble/mention" />
|
||||
<Link rel="http://ostatus.org/schema/1.0/subscribe"
|
||||
template="https://pod.example.tld/follow?url={uri}" />
|
||||
<Link rel="magic-public-key"
|
||||
href="data:application/magic-public-key,RSA.abcdef1234567890" />
|
||||
<Link rel="salmon"
|
||||
href="#{person.salmon_url}" />
|
||||
<Link rel="http://salmon-protocol.org/ns/salmon-replies"
|
||||
href="https://pod.example.tld/salmon/trouble" />
|
||||
<Link rel="http://salmon-protocol.org/ns/salmon-mention"
|
||||
href="https://pod.example.tld/salmon/trouble/mention" />
|
||||
<Link rel="http://ostatus.org/schema/1.0/subscribe"
|
||||
template="https://pod.example.tld/follow?url={uri}" />
|
||||
<Link rel="magic-public-key"
|
||||
href="data:application/magic-public-key,RSA.abcdef1234567890" />
|
||||
|
||||
<Property xmlns:mk="http://salmon-protocol.org/ns/magic-key"
|
||||
type="http://salmon-protocol.org/ns/magic-key"
|
||||
mk:key_id="1">RSA.abcdef1234567890</Property>
|
||||
<Property xmlns:mk="http://salmon-protocol.org/ns/magic-key"
|
||||
type="http://salmon-protocol.org/ns/magic-key"
|
||||
mk:key_id="1">RSA.abcdef1234567890</Property>
|
||||
|
||||
</XRD>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
wf = Discovery::WebFinger.from_xml(friendica_xml)
|
||||
|
|
@ -308,35 +308,35 @@ JSON
|
|||
end
|
||||
|
||||
it "reads redmatrix XML (no alias)" do
|
||||
redmatrix_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
redmatrix_xml = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
|
||||
<Subject>#{person.diaspora_id}</Subject>
|
||||
<Subject>#{person.diaspora_id}</Subject>
|
||||
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from"
|
||||
type="application/atom+xml"
|
||||
href="#{person.atom_url}" />
|
||||
<Link rel="http://webfinger.net/rel/profile-page"
|
||||
type="text/html"
|
||||
href="#{person.profile_url}" />
|
||||
<Link rel="http://portablecontacts.net/spec/1.0"
|
||||
href="https://pod.example.tld/poco/trouble" />
|
||||
<Link rel="http://webfinger.net/rel/avatar"
|
||||
type="image/jpeg"
|
||||
href="http://localhost:3000/assets/user/default.png" />
|
||||
<Link rel="http://microformats.org/profile/hcard"
|
||||
type="text/html"
|
||||
href="#{person.hcard_url}" />
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from"
|
||||
type="application/atom+xml"
|
||||
href="#{person.atom_url}" />
|
||||
<Link rel="http://webfinger.net/rel/profile-page"
|
||||
type="text/html"
|
||||
href="#{person.profile_url}" />
|
||||
<Link rel="http://portablecontacts.net/spec/1.0"
|
||||
href="https://pod.example.tld/poco/trouble" />
|
||||
<Link rel="http://webfinger.net/rel/avatar"
|
||||
type="image/jpeg"
|
||||
href="http://localhost:3000/assets/user/default.png" />
|
||||
<Link rel="http://microformats.org/profile/hcard"
|
||||
type="text/html"
|
||||
href="#{person.hcard_url}" />
|
||||
|
||||
<Link rel="magic-public-key"
|
||||
href="data:application/magic-public-key,RSA.abcdef1234567890" />
|
||||
<Link rel="magic-public-key"
|
||||
href="data:application/magic-public-key,RSA.abcdef1234567890" />
|
||||
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}" />
|
||||
<Link rel="http://joindiaspora.com/guid" type="text/html" href="#{person.guid}" />
|
||||
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}" />
|
||||
<Link rel="http://joindiaspora.com/seed_location" type="text/html" href="#{person.url}" />
|
||||
<Link rel="http://joindiaspora.com/guid" type="text/html" href="#{person.guid}" />
|
||||
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}" />
|
||||
|
||||
</XRD>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
wf = Discovery::WebFinger.from_xml(redmatrix_xml)
|
||||
|
|
@ -349,11 +349,11 @@ JSON
|
|||
end
|
||||
|
||||
it "fails if the document is empty" do
|
||||
invalid_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
</XRD>
|
||||
XML
|
||||
invalid_xml = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
</XRD>
|
||||
XML
|
||||
expect { Discovery::WebFinger.from_xml(invalid_xml) }.to raise_error Discovery::InvalidData
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,50 +2,50 @@
|
|||
|
||||
module DiasporaFederation
|
||||
describe Discovery::XrdDocument do
|
||||
let(:xml) { <<-XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Expires>2010-01-30T09:30:00Z</Expires>
|
||||
<Subject>http://blog.example.com/article/id/314</Subject>
|
||||
<Alias>http://blog.example.com/cool_new_thing</Alias>
|
||||
<Alias>http://blog.example.com/steve/article/7</Alias>
|
||||
<Property type="http://blgx.example.net/ns/version">1.3</Property>
|
||||
<Property type="http://blgx.example.net/ns/ext"/>
|
||||
<Link rel="author" type="text/html" href="http://blog.example.com/author/steve"/>
|
||||
<Link rel="author" href="http://example.com/author/john"/>
|
||||
<Link rel="copyright" template="http://example.com/copyright?id={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Expires>2010-01-30T09:30:00Z</Expires>
|
||||
<Subject>http://blog.example.com/article/id/314</Subject>
|
||||
<Alias>http://blog.example.com/cool_new_thing</Alias>
|
||||
<Alias>http://blog.example.com/steve/article/7</Alias>
|
||||
<Property type="http://blgx.example.net/ns/version">1.3</Property>
|
||||
<Property type="http://blgx.example.net/ns/ext"/>
|
||||
<Link rel="author" type="text/html" href="http://blog.example.com/author/steve"/>
|
||||
<Link rel="author" href="http://example.com/author/john"/>
|
||||
<Link rel="copyright" template="http://example.com/copyright?id={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"subject": "http://blog.example.com/article/id/314",
|
||||
"expires": "2010-01-30T09:30:00Z",
|
||||
"aliases": [
|
||||
"http://blog.example.com/cool_new_thing",
|
||||
"http://blog.example.com/steve/article/7"
|
||||
],
|
||||
"properties": {
|
||||
"http://blgx.example.net/ns/version": "1.3",
|
||||
"http://blgx.example.net/ns/ext": null
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"rel": "author",
|
||||
"type": "text/html",
|
||||
"href": "http://blog.example.com/author/steve"
|
||||
},
|
||||
{
|
||||
"rel": "author",
|
||||
"href": "http://example.com/author/john"
|
||||
},
|
||||
{
|
||||
"rel": "copyright",
|
||||
"template": "http://example.com/copyright?id={uri}"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"subject": "http://blog.example.com/article/id/314",
|
||||
"expires": "2010-01-30T09:30:00Z",
|
||||
"aliases": [
|
||||
"http://blog.example.com/cool_new_thing",
|
||||
"http://blog.example.com/steve/article/7"
|
||||
],
|
||||
"properties": {
|
||||
"http://blgx.example.net/ns/version": "1.3",
|
||||
"http://blgx.example.net/ns/ext": null
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"rel": "author",
|
||||
"type": "text/html",
|
||||
"href": "http://blog.example.com/author/steve"
|
||||
},
|
||||
{
|
||||
"rel": "author",
|
||||
"href": "http://example.com/author/john"
|
||||
},
|
||||
{
|
||||
"rel": "copyright",
|
||||
"template": "http://example.com/copyright?id={uri}"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:data) {
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ module DiasporaFederation
|
|||
describe Entities::AccountDeletion do
|
||||
let(:data) { Fabricate.attributes_for(:account_deletion_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<account_deletion>
|
||||
<author>#{data[:author]}</author>
|
||||
</account_deletion>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<account_deletion>
|
||||
<author>#{data[:author]}</author>
|
||||
</account_deletion>
|
||||
XML
|
||||
|
||||
let(:string) { "AccountDeletion:#{data[:author]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -107,29 +107,29 @@ module DiasporaFederation
|
|||
}
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<account_migration>
|
||||
<author>#{data[:author]}</author>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<signature>#{data[:signature]}</signature>
|
||||
<old_identity>#{data[:old_identity]}</old_identity>
|
||||
</account_migration>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<account_migration>
|
||||
<author>#{data[:author]}</author>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<signature>#{data[:signature]}</signature>
|
||||
<old_identity>#{data[:old_identity]}</old_identity>
|
||||
</account_migration>
|
||||
XML
|
||||
|
||||
it_behaves_like "an account migration entity"
|
||||
end
|
||||
|
|
@ -146,29 +146,29 @@ XML
|
|||
}
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<account_migration>
|
||||
<author>#{data[:author]}</author>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<signature>#{data[:signature]}</signature>
|
||||
<old_identity>#{data[:old_identity]}</old_identity>
|
||||
</account_migration>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<account_migration>
|
||||
<author>#{data[:author]}</author>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<signature>#{data[:signature]}</signature>
|
||||
<old_identity>#{data[:old_identity]}</old_identity>
|
||||
</account_migration>
|
||||
XML
|
||||
|
||||
it_behaves_like "an account migration entity"
|
||||
end
|
||||
|
|
@ -184,28 +184,28 @@ XML
|
|||
}
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<account_migration>
|
||||
<author>#{data[:author]}</author>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<signature>#{data[:signature]}</signature>
|
||||
</account_migration>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<account_migration>
|
||||
<author>#{data[:author]}</author>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<signature>#{data[:signature]}</signature>
|
||||
</account_migration>
|
||||
XML
|
||||
|
||||
it "fails validation on construction" do
|
||||
expect {
|
||||
|
|
|
|||
|
|
@ -14,41 +14,41 @@ module DiasporaFederation
|
|||
).tap {|hash| add_signatures(hash) }
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<comment>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<text>#{data[:text]}</text>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<comment>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<text>#{data[:text]}</text>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</comment>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "comment",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"author_signature": "#{data[:author_signature]}",
|
||||
"text": "#{data[:text]}",
|
||||
"created_at": "#{data[:created_at].iso8601}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}"
|
||||
},
|
||||
"property_order": [
|
||||
"author",
|
||||
"guid",
|
||||
"parent_guid",
|
||||
"text",
|
||||
"created_at",
|
||||
"edited_at"
|
||||
]
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "comment",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"author_signature": "#{data[:author_signature]}",
|
||||
"text": "#{data[:text]}",
|
||||
"created_at": "#{data[:created_at].iso8601}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}"
|
||||
},
|
||||
"property_order": [
|
||||
"author",
|
||||
"guid",
|
||||
"parent_guid",
|
||||
"text",
|
||||
"created_at",
|
||||
"edited_at"
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Comment:#{data[:guid]}:#{parent.guid}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ module DiasporaFederation
|
|||
describe Entities::Contact do
|
||||
let(:data) { Fabricate.attributes_for(:contact_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<contact>
|
||||
<author>#{data[:author]}</author>
|
||||
<recipient>#{data[:recipient]}</recipient>
|
||||
<following>#{data[:following]}</following>
|
||||
<sharing>#{data[:sharing]}</sharing>
|
||||
<blocking>#{data[:blocking]}</blocking>
|
||||
</contact>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<contact>
|
||||
<author>#{data[:author]}</author>
|
||||
<recipient>#{data[:recipient]}</recipient>
|
||||
<following>#{data[:following]}</following>
|
||||
<sharing>#{data[:sharing]}</sharing>
|
||||
<blocking>#{data[:blocking]}</blocking>
|
||||
</contact>
|
||||
XML
|
||||
|
||||
let(:string) { "Contact:#{data[:author]}:#{data[:recipient]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<conversation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{parent.guid}</guid>
|
||||
<subject>#{data[:subject]}</subject>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<participants>#{data[:participants]}</participants>
|
||||
#{data[:messages].map {|a| indent(a.to_xml.to_s, 2) }.join("\n")}
|
||||
</conversation>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<conversation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{parent.guid}</guid>
|
||||
<subject>#{data[:subject]}</subject>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<participants>#{data[:participants]}</participants>
|
||||
#{data[:messages].map {|a| indent(a.to_xml.to_s, 2) }.join("\n")}
|
||||
</conversation>
|
||||
XML
|
||||
|
||||
let(:string) { "Conversation:#{data[:guid]}" }
|
||||
|
||||
|
|
@ -48,15 +48,15 @@ XML
|
|||
|
||||
context "default values" do
|
||||
it "allows no nested messages" do
|
||||
minimal_xml = <<-XML
|
||||
<conversation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{parent.guid}</guid>
|
||||
<subject>#{data[:subject]}</subject>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<participant_handles>#{data[:participants]}</participant_handles>
|
||||
</conversation>
|
||||
XML
|
||||
minimal_xml = <<~XML
|
||||
<conversation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{parent.guid}</guid>
|
||||
<subject>#{data[:subject]}</subject>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<participant_handles>#{data[:participants]}</participant_handles>
|
||||
</conversation>
|
||||
XML
|
||||
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML(minimal_xml).root)
|
||||
expect(parsed_instance.messages).to eq([])
|
||||
|
|
|
|||
|
|
@ -4,26 +4,26 @@ module DiasporaFederation
|
|||
describe Entities::Embed do
|
||||
let(:data) { Fabricate.attributes_for(:embed_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<embed>
|
||||
<url>#{data[:url]}</url>
|
||||
<title>#{data[:title]}</title>
|
||||
<description>#{data[:description]}</description>
|
||||
<image>#{data[:image]}</image>
|
||||
</embed>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<embed>
|
||||
<url>#{data[:url]}</url>
|
||||
<title>#{data[:title]}</title>
|
||||
<description>#{data[:description]}</description>
|
||||
<image>#{data[:image]}</image>
|
||||
</embed>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "embed",
|
||||
"entity_data": {
|
||||
"url": "#{data[:url]}",
|
||||
"title": "#{data[:title]}",
|
||||
"description": "#{data[:description]}",
|
||||
"image": "#{data[:image]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "embed",
|
||||
"entity_data": {
|
||||
"url": "#{data[:url]}",
|
||||
"title": "#{data[:title]}",
|
||||
"description": "#{data[:description]}",
|
||||
"image": "#{data[:image]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Embed:#{data[:url]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,17 +13,17 @@ module DiasporaFederation
|
|||
).tap {|hash| add_signatures(hash) }
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<event_participation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<status>#{data[:status]}</status>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</event_participation>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<event_participation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<status>#{data[:status]}</status>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</event_participation>
|
||||
XML
|
||||
|
||||
let(:string) { "EventParticipation:#{data[:guid]}:#{parent.guid}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,24 +7,24 @@ module DiasporaFederation
|
|||
Fabricate.attributes_for(:event_entity).merge(author: alice.diaspora_id, location: location)
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<event>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<summary>#{data[:summary]}</summary>
|
||||
<description>#{data[:description]}</description>
|
||||
<start>#{data[:start].utc.iso8601}</start>
|
||||
<end>#{data[:end].utc.iso8601}</end>
|
||||
<all_day>#{data[:all_day]}</all_day>
|
||||
<timezone>#{data[:timezone]}</timezone>
|
||||
<location>
|
||||
<address>#{location.address}</address>
|
||||
<lat>#{location.lat}</lat>
|
||||
<lng>#{location.lng}</lng>
|
||||
</location>
|
||||
</event>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<event>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<summary>#{data[:summary]}</summary>
|
||||
<description>#{data[:description]}</description>
|
||||
<start>#{data[:start].utc.iso8601}</start>
|
||||
<end>#{data[:end].utc.iso8601}</end>
|
||||
<all_day>#{data[:all_day]}</all_day>
|
||||
<timezone>#{data[:timezone]}</timezone>
|
||||
<location>
|
||||
<address>#{location.address}</address>
|
||||
<lat>#{location.lat}</lat>
|
||||
<lng>#{location.lng}</lng>
|
||||
</location>
|
||||
</event>
|
||||
XML
|
||||
|
||||
let(:string) { "Event:#{data[:guid]}" }
|
||||
|
||||
|
|
@ -34,14 +34,14 @@ XML
|
|||
|
||||
context "default values" do
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<event>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<summary>#{data[:summary]}</summary>
|
||||
<start>#{data[:start].utc.iso8601}</start>
|
||||
</event>
|
||||
XML
|
||||
minimal_xml = <<~XML
|
||||
<event>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<summary>#{data[:summary]}</summary>
|
||||
<start>#{data[:start].utc.iso8601}</start>
|
||||
</event>
|
||||
XML
|
||||
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML(minimal_xml).root)
|
||||
expect(parsed_instance.end).to be_nil
|
||||
|
|
|
|||
|
|
@ -14,38 +14,38 @@ module DiasporaFederation
|
|||
).tap {|hash| add_signatures(hash) }
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<like>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<parent_type>#{parent.entity_type}</parent_type>
|
||||
<positive>#{data[:positive]}</positive>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</like>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<like>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<parent_type>#{parent.entity_type}</parent_type>
|
||||
<positive>#{data[:positive]}</positive>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</like>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "like",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"author_signature": "#{data[:author_signature]}",
|
||||
"parent_type": "#{parent.entity_type}",
|
||||
"positive": #{data[:positive]}
|
||||
},
|
||||
"property_order": [
|
||||
"author",
|
||||
"guid",
|
||||
"parent_guid",
|
||||
"parent_type",
|
||||
"positive"
|
||||
]
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "like",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"author_signature": "#{data[:author_signature]}",
|
||||
"parent_type": "#{parent.entity_type}",
|
||||
"positive": #{data[:positive]}
|
||||
},
|
||||
"property_order": [
|
||||
"author",
|
||||
"guid",
|
||||
"parent_guid",
|
||||
"parent_type",
|
||||
"positive"
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Like:#{data[:guid]}:Post:#{parent.guid}" }
|
||||
|
||||
|
|
@ -61,11 +61,11 @@ JSON
|
|||
|
||||
context "invalid XML" do
|
||||
it "raises a ValidationError if the parent_type is missing" do
|
||||
broken_xml = <<-XML
|
||||
<like>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
</like>
|
||||
XML
|
||||
broken_xml = <<~XML
|
||||
<like>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
</like>
|
||||
XML
|
||||
|
||||
expect {
|
||||
DiasporaFederation::Entities::Like.from_xml(Nokogiri::XML(broken_xml).root)
|
||||
|
|
@ -73,11 +73,11 @@ XML
|
|||
end
|
||||
|
||||
it "raises a ValidationError if the parent_guid is missing" do
|
||||
broken_xml = <<-XML
|
||||
<like>
|
||||
<target_type>#{parent.entity_type}</target_type>
|
||||
</like>
|
||||
XML
|
||||
broken_xml = <<~XML
|
||||
<like>
|
||||
<target_type>#{parent.entity_type}</target_type>
|
||||
</like>
|
||||
XML
|
||||
|
||||
expect {
|
||||
DiasporaFederation::Entities::Like.from_xml(Nokogiri::XML(broken_xml).root)
|
||||
|
|
|
|||
|
|
@ -4,24 +4,24 @@ module DiasporaFederation
|
|||
describe Entities::Location do
|
||||
let(:data) { Fabricate.attributes_for(:location_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<location>
|
||||
<address>#{data[:address]}</address>
|
||||
<lat>#{data[:lat]}</lat>
|
||||
<lng>#{data[:lng]}</lng>
|
||||
</location>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<location>
|
||||
<address>#{data[:address]}</address>
|
||||
<lat>#{data[:lat]}</lat>
|
||||
<lng>#{data[:lng]}</lng>
|
||||
</location>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "location",
|
||||
"entity_data": {
|
||||
"address": "#{data[:address]}",
|
||||
"lat": "#{data[:lat]}",
|
||||
"lng": "#{data[:lng]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "location",
|
||||
"entity_data": {
|
||||
"address": "#{data[:address]}",
|
||||
"lat": "#{data[:lat]}",
|
||||
"lng": "#{data[:lng]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Location" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ module DiasporaFederation
|
|||
describe Entities::Message do
|
||||
let(:data) { Fabricate.attributes_for(:message_entity, author: alice.diaspora_id) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<text>#{data[:text]}</text>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<conversation_guid>#{data[:conversation_guid]}</conversation_guid>
|
||||
</message>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<text>#{data[:text]}</text>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<conversation_guid>#{data[:conversation_guid]}</conversation_guid>
|
||||
</message>
|
||||
XML
|
||||
|
||||
let(:string) { "Message:#{data[:guid]}:#{data[:conversation_guid]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -12,26 +12,26 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<participation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<parent_type>#{parent.entity_type}</parent_type>
|
||||
</participation>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<participation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<parent_type>#{parent.entity_type}</parent_type>
|
||||
</participation>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "participation",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"parent_type": "#{parent.entity_type}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "participation",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"parent_type": "#{parent.entity_type}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Participation:#{data[:guid]}:Post:#{parent.guid}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,31 +4,31 @@ module DiasporaFederation
|
|||
describe Entities::Person do
|
||||
let(:data) { Fabricate.attributes_for(:person_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<person>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
<url>#{data[:url]}</url>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<edited_at>#{data[:profile].edited_at.utc.iso8601}</edited_at>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<exported_key>#{data[:exported_key]}</exported_key>
|
||||
</person>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<person>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
<url>#{data[:url]}</url>
|
||||
<profile>
|
||||
<author>#{data[:profile].author}</author>
|
||||
<edited_at>#{data[:profile].edited_at.utc.iso8601}</edited_at>
|
||||
<full_name>#{data[:profile].full_name}</full_name>
|
||||
<first_name>#{data[:profile].first_name}</first_name>
|
||||
<image_url>#{data[:profile].image_url}</image_url>
|
||||
<image_url_medium>#{data[:profile].image_url}</image_url_medium>
|
||||
<image_url_small>#{data[:profile].image_url}</image_url_small>
|
||||
<bio>#{data[:profile].bio}</bio>
|
||||
<birthday>#{data[:profile].birthday}</birthday>
|
||||
<gender>#{data[:profile].gender}</gender>
|
||||
<location>#{data[:profile].location}</location>
|
||||
<searchable>#{data[:profile].searchable}</searchable>
|
||||
<public>#{data[:profile].public}</public>
|
||||
<nsfw>#{data[:profile].nsfw}</nsfw>
|
||||
<tag_string>#{data[:profile].tag_string}</tag_string>
|
||||
</profile>
|
||||
<exported_key>#{data[:exported_key]}</exported_key>
|
||||
</person>
|
||||
XML
|
||||
|
||||
let(:string) { "Person:#{data[:guid]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,40 +4,40 @@ module DiasporaFederation
|
|||
describe Entities::Photo do
|
||||
let(:data) { Fabricate.attributes_for(:photo_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<photo>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
<public>#{data[:public]}</public>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
|
||||
<remote_photo_name>#{data[:remote_photo_name]}</remote_photo_name>
|
||||
<text>#{data[:text]}</text>
|
||||
<status_message_guid>#{data[:status_message_guid]}</status_message_guid>
|
||||
<height>#{data[:height]}</height>
|
||||
<width>#{data[:width]}</width>
|
||||
</photo>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<photo>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
<public>#{data[:public]}</public>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
|
||||
<remote_photo_name>#{data[:remote_photo_name]}</remote_photo_name>
|
||||
<text>#{data[:text]}</text>
|
||||
<status_message_guid>#{data[:status_message_guid]}</status_message_guid>
|
||||
<height>#{data[:height]}</height>
|
||||
<width>#{data[:width]}</width>
|
||||
</photo>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "photo",
|
||||
"entity_data": {
|
||||
"guid": "#{data[:guid]}",
|
||||
"author": "#{data[:author]}",
|
||||
"public": #{data[:public]},
|
||||
"created_at": "#{data[:created_at].utc.iso8601}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}",
|
||||
"remote_photo_path": "#{data[:remote_photo_path]}",
|
||||
"remote_photo_name": "#{data[:remote_photo_name]}",
|
||||
"text": "#{data[:text]}",
|
||||
"status_message_guid": "#{data[:status_message_guid]}",
|
||||
"height": #{data[:height]},
|
||||
"width": #{data[:width]}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "photo",
|
||||
"entity_data": {
|
||||
"guid": "#{data[:guid]}",
|
||||
"author": "#{data[:author]}",
|
||||
"public": #{data[:public]},
|
||||
"created_at": "#{data[:created_at].utc.iso8601}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}",
|
||||
"remote_photo_path": "#{data[:remote_photo_path]}",
|
||||
"remote_photo_name": "#{data[:remote_photo_name]}",
|
||||
"text": "#{data[:text]}",
|
||||
"status_message_guid": "#{data[:status_message_guid]}",
|
||||
"height": #{data[:height]},
|
||||
"width": #{data[:width]}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Photo:#{data[:guid]}" }
|
||||
|
||||
|
|
@ -49,18 +49,18 @@ JSON
|
|||
|
||||
context "default values" do
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<photo>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
|
||||
<remote_photo_name>#{data[:remote_photo_name]}</remote_photo_name>
|
||||
<status_message_guid>#{data[:status_message_guid]}</status_message_guid>
|
||||
<height>#{data[:height]}</height>
|
||||
<width>#{data[:width]}</width>
|
||||
</photo>
|
||||
XML
|
||||
minimal_xml = <<~XML
|
||||
<photo>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<author>#{data[:author]}</author>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
|
||||
<remote_photo_name>#{data[:remote_photo_name]}</remote_photo_name>
|
||||
<status_message_guid>#{data[:status_message_guid]}</status_message_guid>
|
||||
<height>#{data[:height]}</height>
|
||||
<width>#{data[:width]}</width>
|
||||
</photo>
|
||||
XML
|
||||
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML(minimal_xml).root)
|
||||
expect(parsed_instance.public).to be_falsey
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@ module DiasporaFederation
|
|||
describe Entities::PollAnswer do
|
||||
let(:data) { Fabricate.attributes_for(:poll_answer_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<poll_answer>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<answer>#{data[:answer]}</answer>
|
||||
</poll_answer>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<poll_answer>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<answer>#{data[:answer]}</answer>
|
||||
</poll_answer>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "poll_answer",
|
||||
"entity_data": {
|
||||
"guid": "#{data[:guid]}",
|
||||
"answer": "#{data[:answer]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "poll_answer",
|
||||
"entity_data": {
|
||||
"guid": "#{data[:guid]}",
|
||||
"answer": "#{data[:answer]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "PollAnswer:#{data[:guid]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,35 +13,35 @@ module DiasporaFederation
|
|||
).tap {|hash| add_signatures(hash) }
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<poll_participation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<poll_answer_guid>#{data[:poll_answer_guid]}</poll_answer_guid>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</poll_participation>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<poll_participation>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{parent.guid}</parent_guid>
|
||||
<poll_answer_guid>#{data[:poll_answer_guid]}</poll_answer_guid>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
</poll_participation>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "poll_participation",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"author_signature": "#{data[:author_signature]}",
|
||||
"poll_answer_guid": "#{data[:poll_answer_guid]}"
|
||||
},
|
||||
"property_order": [
|
||||
"author",
|
||||
"guid",
|
||||
"parent_guid",
|
||||
"poll_answer_guid"
|
||||
]
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "poll_participation",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"parent_guid": "#{parent.guid}",
|
||||
"author_signature": "#{data[:author_signature]}",
|
||||
"poll_answer_guid": "#{data[:poll_answer_guid]}"
|
||||
},
|
||||
"property_order": [
|
||||
"author",
|
||||
"guid",
|
||||
"parent_guid",
|
||||
"poll_answer_guid"
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "PollParticipation:#{data[:guid]}:#{parent.guid}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,26 +4,26 @@ module DiasporaFederation
|
|||
describe Entities::Poll do
|
||||
let(:data) { Fabricate.attributes_for(:poll_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<poll>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<question>#{data[:question]}</question>
|
||||
#{data[:poll_answers].map {|a| indent(a.to_xml.to_s, 2) }.join("\n")}
|
||||
</poll>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<poll>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<question>#{data[:question]}</question>
|
||||
#{data[:poll_answers].map {|a| indent(a.to_xml.to_s, 2) }.join("\n")}
|
||||
</poll>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "poll",
|
||||
"entity_data": {
|
||||
"guid": "#{data[:guid]}",
|
||||
"question": "#{data[:question]}",
|
||||
"poll_answers": [
|
||||
#{data[:poll_answers].map {|a| indent(JSON.pretty_generate(a.to_json), 6) }.join(",\n")}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "poll",
|
||||
"entity_data": {
|
||||
"guid": "#{data[:guid]}",
|
||||
"question": "#{data[:question]}",
|
||||
"poll_answers": [
|
||||
#{data[:poll_answers].map {|a| indent(JSON.pretty_generate(a.to_json), 6) }.join(",\n")}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Poll:#{data[:guid]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,48 +4,48 @@ module DiasporaFederation
|
|||
describe Entities::Profile do
|
||||
let(:data) { Fabricate.attributes_for(:profile_entity) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<profile>
|
||||
<author>#{data[:author]}</author>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<full_name>#{data[:full_name]}</full_name>
|
||||
<first_name>#{data[:first_name]}</first_name>
|
||||
<image_url>#{data[:image_url]}</image_url>
|
||||
<image_url_medium>#{data[:image_url]}</image_url_medium>
|
||||
<image_url_small>#{data[:image_url]}</image_url_small>
|
||||
<bio>#{data[:bio]}</bio>
|
||||
<birthday>#{data[:birthday]}</birthday>
|
||||
<gender>#{data[:gender]}</gender>
|
||||
<location>#{data[:location]}</location>
|
||||
<searchable>#{data[:searchable]}</searchable>
|
||||
<public>#{data[:public]}</public>
|
||||
<nsfw>#{data[:nsfw]}</nsfw>
|
||||
<tag_string>#{data[:tag_string]}</tag_string>
|
||||
</profile>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<profile>
|
||||
<author>#{data[:author]}</author>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<full_name>#{data[:full_name]}</full_name>
|
||||
<first_name>#{data[:first_name]}</first_name>
|
||||
<image_url>#{data[:image_url]}</image_url>
|
||||
<image_url_medium>#{data[:image_url]}</image_url_medium>
|
||||
<image_url_small>#{data[:image_url]}</image_url_small>
|
||||
<bio>#{data[:bio]}</bio>
|
||||
<birthday>#{data[:birthday]}</birthday>
|
||||
<gender>#{data[:gender]}</gender>
|
||||
<location>#{data[:location]}</location>
|
||||
<searchable>#{data[:searchable]}</searchable>
|
||||
<public>#{data[:public]}</public>
|
||||
<nsfw>#{data[:nsfw]}</nsfw>
|
||||
<tag_string>#{data[:tag_string]}</tag_string>
|
||||
</profile>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "profile",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}",
|
||||
"full_name": "#{data[:full_name]}",
|
||||
"first_name": "#{data[:first_name]}",
|
||||
"image_url": "#{data[:image_url]}",
|
||||
"image_url_medium": "#{data[:image_url]}",
|
||||
"image_url_small": "#{data[:image_url]}",
|
||||
"bio": "#{data[:bio]}",
|
||||
"birthday": "#{data[:birthday]}",
|
||||
"gender": "#{data[:gender]}",
|
||||
"location": "#{data[:location]}",
|
||||
"searchable": #{data[:searchable]},
|
||||
"public": #{data[:public]},
|
||||
"nsfw": #{data[:nsfw]},
|
||||
"tag_string": "#{data[:tag_string]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "profile",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}",
|
||||
"full_name": "#{data[:full_name]}",
|
||||
"first_name": "#{data[:first_name]}",
|
||||
"image_url": "#{data[:image_url]}",
|
||||
"image_url_medium": "#{data[:image_url]}",
|
||||
"image_url_small": "#{data[:image_url]}",
|
||||
"bio": "#{data[:bio]}",
|
||||
"birthday": "#{data[:birthday]}",
|
||||
"gender": "#{data[:gender]}",
|
||||
"location": "#{data[:location]}",
|
||||
"searchable": #{data[:searchable]},
|
||||
"public": #{data[:public]},
|
||||
"nsfw": #{data[:nsfw]},
|
||||
"tag_string": "#{data[:tag_string]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Profile:#{data[:author]}" }
|
||||
|
||||
|
|
@ -57,11 +57,11 @@ JSON
|
|||
|
||||
context "default values" do
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<profile>
|
||||
<author>#{data[:author]}</author>
|
||||
</profile>
|
||||
XML
|
||||
minimal_xml = <<~XML
|
||||
<profile>
|
||||
<author>#{data[:author]}</author>
|
||||
</profile>
|
||||
XML
|
||||
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML(minimal_xml).root)
|
||||
expect(parsed_instance.full_name).to be_nil
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ module DiasporaFederation
|
|||
}
|
||||
let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<relayable_retraction>
|
||||
<parent_author_signature/>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<target_author_signature/>
|
||||
</relayable_retraction>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<relayable_retraction>
|
||||
<parent_author_signature/>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<target_author_signature/>
|
||||
</relayable_retraction>
|
||||
XML
|
||||
|
||||
describe "#initialize" do
|
||||
it "raises because it is not supported anymore" do
|
||||
|
|
|
|||
|
|
@ -122,17 +122,17 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
describe "#to_xml" do
|
||||
let(:expected_xml) { <<-XML }
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<property>#{property}</property>
|
||||
<new_property>#{new_property}</new_property>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
let(:expected_xml) { <<~XML }
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<property>#{property}</property>
|
||||
<new_property>#{new_property}</new_property>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
it "adds new unknown xml elements to the xml again" do
|
||||
signature_order = [:author, :guid, :parent_guid, :property, "new_property"]
|
||||
|
|
@ -161,17 +161,17 @@ XML
|
|||
end
|
||||
|
||||
it "adds nil properties to xml when needed for signature_order" do
|
||||
expected_xml = <<-XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<property/>
|
||||
<new_property>#{new_property}</new_property>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
expected_xml = <<~XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<property/>
|
||||
<new_property>#{new_property}</new_property>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
signature_order = [:author, :guid, :parent_guid, :property, "new_property"]
|
||||
xml = Entities::SomeRelayable.new(
|
||||
|
|
@ -182,15 +182,15 @@ XML
|
|||
end
|
||||
|
||||
it "does not add nil properties to xml when not needed for signature_order" do
|
||||
expected_xml = <<-XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
expected_xml = <<~XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
xml = Entities::SomeRelayable.new(hash_with_fake_signatures.merge(property: nil)).to_xml
|
||||
|
||||
|
|
@ -283,16 +283,16 @@ XML
|
|||
end
|
||||
|
||||
it "adds 'false' booleans" do
|
||||
expected_xml = <<-XML
|
||||
<test_relayable_with_boolean>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<test>false</test>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</test_relayable_with_boolean>
|
||||
XML
|
||||
expected_xml = <<~XML
|
||||
<test_relayable_with_boolean>
|
||||
<author>#{author}</author>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<test>false</test>
|
||||
<author_signature>aa</author_signature>
|
||||
<parent_author_signature>bb</parent_author_signature>
|
||||
</test_relayable_with_boolean>
|
||||
XML
|
||||
|
||||
xml = Entities::TestRelayableWithBoolean.new(hash_with_fake_signatures.merge(test: false)).to_xml
|
||||
|
||||
|
|
@ -308,17 +308,17 @@ XML
|
|||
end
|
||||
|
||||
let(:new_signature_data) { "#{author};#{guid};#{parent_guid};#{new_property};#{property}" }
|
||||
let(:new_xml) { <<-XML }
|
||||
<some_relayable>
|
||||
<diaspora_handle>#{author}</diaspora_handle>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<new_property>#{new_property}</new_property>
|
||||
<property>#{property}</property>
|
||||
<author_signature>#{sign_with_key(author_pkey, new_signature_data)}</author_signature>
|
||||
<parent_author_signature>#{sign_with_key(parent_pkey, new_signature_data)}</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
let(:new_xml) { <<~XML }
|
||||
<some_relayable>
|
||||
<diaspora_handle>#{author}</diaspora_handle>
|
||||
<guid>#{guid}</guid>
|
||||
<parent_guid>#{parent_guid}</parent_guid>
|
||||
<new_property>#{new_property}</new_property>
|
||||
<property>#{property}</property>
|
||||
<author_signature>#{sign_with_key(author_pkey, new_signature_data)}</author_signature>
|
||||
<parent_author_signature>#{sign_with_key(parent_pkey, new_signature_data)}</parent_author_signature>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
it "doesn't drop unknown properties" do
|
||||
entity = Entities::SomeRelayable.from_xml(Nokogiri::XML(new_xml).root)
|
||||
|
|
@ -352,10 +352,10 @@ XML
|
|||
|
||||
context "parse invalid XML" do
|
||||
it "raises a ValidationError if the parent_guid is missing" do
|
||||
broken_xml = <<-XML
|
||||
<some_relayable>
|
||||
</some_relayable>
|
||||
XML
|
||||
broken_xml = <<~XML
|
||||
<some_relayable>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
expect {
|
||||
Entities::SomeRelayable.from_xml(Nokogiri::XML(broken_xml).root)
|
||||
|
|
@ -363,11 +363,11 @@ XML
|
|||
end
|
||||
|
||||
it "adds the guid to the error message if available" do
|
||||
broken_xml = <<-XML
|
||||
<some_relayable>
|
||||
<guid>#{guid}</guid>
|
||||
</some_relayable>
|
||||
XML
|
||||
broken_xml = <<~XML
|
||||
<some_relayable>
|
||||
<guid>#{guid}</guid>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
expect {
|
||||
Entities::SomeRelayable.from_xml(Nokogiri::XML(broken_xml).root)
|
||||
|
|
@ -375,11 +375,11 @@ XML
|
|||
end
|
||||
|
||||
it "adds the author to the error message if available" do
|
||||
broken_xml = <<-XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
</some_relayable>
|
||||
XML
|
||||
broken_xml = <<~XML
|
||||
<some_relayable>
|
||||
<author>#{author}</author>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
expect {
|
||||
Entities::SomeRelayable.from_xml(Nokogiri::XML(broken_xml).root)
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ module DiasporaFederation
|
|||
describe Entities::Request do
|
||||
let(:data) { {author: Fabricate.sequence(:diaspora_id), recipient: Fabricate.sequence(:diaspora_id)} }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<request>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<recipient_handle>#{data[:recipient]}</recipient_handle>
|
||||
</request>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<request>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<recipient_handle>#{data[:recipient]}</recipient_handle>
|
||||
</request>
|
||||
XML
|
||||
|
||||
describe "#initialize" do
|
||||
it "raises because it is not supported anymore" do
|
||||
|
|
|
|||
|
|
@ -5,28 +5,28 @@ module DiasporaFederation
|
|||
let(:root) { Fabricate(:post, author: bob) }
|
||||
let(:data) { Fabricate.attributes_for(:reshare_entity, root_guid: root.guid, root_author: bob.diaspora_id) }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<reshare>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<root_author>#{data[:root_author]}</root_author>
|
||||
<root_guid>#{data[:root_guid]}</root_guid>
|
||||
</reshare>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<reshare>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<root_author>#{data[:root_author]}</root_author>
|
||||
<root_guid>#{data[:root_guid]}</root_guid>
|
||||
</reshare>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "reshare",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"created_at": "#{data[:created_at].utc.iso8601}",
|
||||
"root_author": "#{data[:root_author]}",
|
||||
"root_guid": "#{data[:root_guid]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "reshare",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"created_at": "#{data[:created_at].utc.iso8601}",
|
||||
"root_author": "#{data[:root_author]}",
|
||||
"root_guid": "#{data[:root_guid]}"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
let(:string) { "Reshare:#{data[:guid]}:#{data[:root_guid]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<retraction>
|
||||
<author>#{data[:author]}</author>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
</retraction>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<retraction>
|
||||
<author>#{data[:author]}</author>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
</retraction>
|
||||
XML
|
||||
|
||||
let(:string) { "Retraction:#{data[:target_type]}:#{data[:target_guid]}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ module DiasporaFederation
|
|||
let(:target_entity) { Fabricate(:related_entity, author: alice.diaspora_id) }
|
||||
let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<signed_retraction>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<target_author_signature/>
|
||||
</signed_retraction>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<signed_retraction>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<target_author_signature/>
|
||||
</signed_retraction>
|
||||
XML
|
||||
|
||||
describe "#initialize" do
|
||||
it "raises because it is not supported anymore" do
|
||||
|
|
|
|||
|
|
@ -17,105 +17,105 @@ module DiasporaFederation
|
|||
)
|
||||
}
|
||||
|
||||
let(:xml) { <<-XML }
|
||||
<status_message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<public>#{data[:public]}</public>
|
||||
<provider_display_name>#{data[:provider_display_name]}</provider_display_name>
|
||||
<text>#{data[:text]}</text>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<photo>
|
||||
<guid>#{photo1.guid}</guid>
|
||||
<author>#{photo1.author}</author>
|
||||
<public>#{photo1.public}</public>
|
||||
<created_at>#{photo1.created_at.utc.iso8601}</created_at>
|
||||
<edited_at>#{photo1.edited_at.utc.iso8601}</edited_at>
|
||||
<remote_photo_path>#{photo1.remote_photo_path}</remote_photo_path>
|
||||
<remote_photo_name>#{photo1.remote_photo_name}</remote_photo_name>
|
||||
<text>#{photo1.text}</text>
|
||||
<status_message_guid>#{photo1.status_message_guid}</status_message_guid>
|
||||
<height>#{photo1.height}</height>
|
||||
<width>#{photo1.width}</width>
|
||||
</photo>
|
||||
<photo>
|
||||
<guid>#{photo2.guid}</guid>
|
||||
<author>#{photo2.author}</author>
|
||||
<public>#{photo2.public}</public>
|
||||
<created_at>#{photo2.created_at.utc.iso8601}</created_at>
|
||||
<edited_at>#{photo2.edited_at.utc.iso8601}</edited_at>
|
||||
<remote_photo_path>#{photo2.remote_photo_path}</remote_photo_path>
|
||||
<remote_photo_name>#{photo2.remote_photo_name}</remote_photo_name>
|
||||
<text>#{photo2.text}</text>
|
||||
<status_message_guid>#{photo2.status_message_guid}</status_message_guid>
|
||||
<height>#{photo2.height}</height>
|
||||
<width>#{photo2.width}</width>
|
||||
</photo>
|
||||
<location>
|
||||
<address>#{location.address}</address>
|
||||
<lat>#{location.lat}</lat>
|
||||
<lng>#{location.lng}</lng>
|
||||
</location>
|
||||
</status_message>
|
||||
XML
|
||||
let(:xml) { <<~XML }
|
||||
<status_message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at].utc.iso8601}</created_at>
|
||||
<public>#{data[:public]}</public>
|
||||
<provider_display_name>#{data[:provider_display_name]}</provider_display_name>
|
||||
<text>#{data[:text]}</text>
|
||||
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
|
||||
<photo>
|
||||
<guid>#{photo1.guid}</guid>
|
||||
<author>#{photo1.author}</author>
|
||||
<public>#{photo1.public}</public>
|
||||
<created_at>#{photo1.created_at.utc.iso8601}</created_at>
|
||||
<edited_at>#{photo1.edited_at.utc.iso8601}</edited_at>
|
||||
<remote_photo_path>#{photo1.remote_photo_path}</remote_photo_path>
|
||||
<remote_photo_name>#{photo1.remote_photo_name}</remote_photo_name>
|
||||
<text>#{photo1.text}</text>
|
||||
<status_message_guid>#{photo1.status_message_guid}</status_message_guid>
|
||||
<height>#{photo1.height}</height>
|
||||
<width>#{photo1.width}</width>
|
||||
</photo>
|
||||
<photo>
|
||||
<guid>#{photo2.guid}</guid>
|
||||
<author>#{photo2.author}</author>
|
||||
<public>#{photo2.public}</public>
|
||||
<created_at>#{photo2.created_at.utc.iso8601}</created_at>
|
||||
<edited_at>#{photo2.edited_at.utc.iso8601}</edited_at>
|
||||
<remote_photo_path>#{photo2.remote_photo_path}</remote_photo_path>
|
||||
<remote_photo_name>#{photo2.remote_photo_name}</remote_photo_name>
|
||||
<text>#{photo2.text}</text>
|
||||
<status_message_guid>#{photo2.status_message_guid}</status_message_guid>
|
||||
<height>#{photo2.height}</height>
|
||||
<width>#{photo2.width}</width>
|
||||
</photo>
|
||||
<location>
|
||||
<address>#{location.address}</address>
|
||||
<lat>#{location.lat}</lat>
|
||||
<lng>#{location.lng}</lng>
|
||||
</location>
|
||||
</status_message>
|
||||
XML
|
||||
|
||||
let(:json) { <<-JSON }
|
||||
{
|
||||
"entity_type": "status_message",
|
||||
"entity_data": {
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"created_at": "#{data[:created_at].utc.iso8601}",
|
||||
"public": #{data[:public]},
|
||||
"provider_display_name": "#{data[:provider_display_name]}",
|
||||
"text": "#{data[:text]}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}",
|
||||
"photos": [
|
||||
let(:json) { <<~JSON }
|
||||
{
|
||||
"entity_type": "photo",
|
||||
"entity_type": "status_message",
|
||||
"entity_data": {
|
||||
"guid": "#{photo1.guid}",
|
||||
"author": "#{photo1.author}",
|
||||
"public": #{photo1.public},
|
||||
"created_at": "#{photo1.created_at.utc.iso8601}",
|
||||
"edited_at": "#{photo1.edited_at.utc.iso8601}",
|
||||
"remote_photo_path": "#{photo1.remote_photo_path}",
|
||||
"remote_photo_name": "#{photo1.remote_photo_name}",
|
||||
"text": "#{photo1.text}",
|
||||
"status_message_guid": "#{photo1.status_message_guid}",
|
||||
"height": #{photo1.height},
|
||||
"width": #{photo1.width}
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity_type": "photo",
|
||||
"entity_data": {
|
||||
"guid": "#{photo2.guid}",
|
||||
"author": "#{photo2.author}",
|
||||
"public": #{photo2.public},
|
||||
"created_at": "#{photo2.created_at.utc.iso8601}",
|
||||
"edited_at": "#{photo2.edited_at.utc.iso8601}",
|
||||
"remote_photo_path": "#{photo2.remote_photo_path}",
|
||||
"remote_photo_name": "#{photo2.remote_photo_name}",
|
||||
"text": "#{photo2.text}",
|
||||
"status_message_guid": "#{photo2.status_message_guid}",
|
||||
"height": #{photo2.height},
|
||||
"width": #{photo2.width}
|
||||
"author": "#{data[:author]}",
|
||||
"guid": "#{data[:guid]}",
|
||||
"created_at": "#{data[:created_at].utc.iso8601}",
|
||||
"public": #{data[:public]},
|
||||
"provider_display_name": "#{data[:provider_display_name]}",
|
||||
"text": "#{data[:text]}",
|
||||
"edited_at": "#{data[:edited_at].iso8601}",
|
||||
"photos": [
|
||||
{
|
||||
"entity_type": "photo",
|
||||
"entity_data": {
|
||||
"guid": "#{photo1.guid}",
|
||||
"author": "#{photo1.author}",
|
||||
"public": #{photo1.public},
|
||||
"created_at": "#{photo1.created_at.utc.iso8601}",
|
||||
"edited_at": "#{photo1.edited_at.utc.iso8601}",
|
||||
"remote_photo_path": "#{photo1.remote_photo_path}",
|
||||
"remote_photo_name": "#{photo1.remote_photo_name}",
|
||||
"text": "#{photo1.text}",
|
||||
"status_message_guid": "#{photo1.status_message_guid}",
|
||||
"height": #{photo1.height},
|
||||
"width": #{photo1.width}
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity_type": "photo",
|
||||
"entity_data": {
|
||||
"guid": "#{photo2.guid}",
|
||||
"author": "#{photo2.author}",
|
||||
"public": #{photo2.public},
|
||||
"created_at": "#{photo2.created_at.utc.iso8601}",
|
||||
"edited_at": "#{photo2.edited_at.utc.iso8601}",
|
||||
"remote_photo_path": "#{photo2.remote_photo_path}",
|
||||
"remote_photo_name": "#{photo2.remote_photo_name}",
|
||||
"text": "#{photo2.text}",
|
||||
"status_message_guid": "#{photo2.status_message_guid}",
|
||||
"height": #{photo2.height},
|
||||
"width": #{photo2.width}
|
||||
}
|
||||
}
|
||||
],
|
||||
"location": {
|
||||
"entity_type": "location",
|
||||
"entity_data": {
|
||||
"address": "#{location.address}",
|
||||
"lat": "#{location.lat}",
|
||||
"lng": "#{location.lng}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"location": {
|
||||
"entity_type": "location",
|
||||
"entity_data": {
|
||||
"address": "#{location.address}",
|
||||
"lat": "#{location.lat}",
|
||||
"lng": "#{location.lng}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
JSON
|
||||
|
||||
let(:string) { "StatusMessage:#{data[:guid]}" }
|
||||
|
||||
|
|
@ -127,14 +127,14 @@ JSON
|
|||
|
||||
context "default values" do
|
||||
it "uses default values" do
|
||||
minimal_xml = <<-XML
|
||||
<status_message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<text>#{data[:text]}</text>
|
||||
</status_message>
|
||||
XML
|
||||
minimal_xml = <<~XML
|
||||
<status_message>
|
||||
<author>#{data[:author]}</author>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<text>#{data[:text]}</text>
|
||||
</status_message>
|
||||
XML
|
||||
|
||||
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML(minimal_xml).root)
|
||||
expect(parsed_instance.photos).to eq([])
|
||||
|
|
|
|||
|
|
@ -204,13 +204,13 @@ module DiasporaFederation
|
|||
test2: "qwer",
|
||||
test3: true
|
||||
)
|
||||
Entities::TestDefaultEntity.from_xml(Nokogiri::XML(<<-XML).root)
|
||||
<test_default_entity>
|
||||
<test1>asdf</test1>
|
||||
<test2>qwer</qwer2>
|
||||
<test3>true</qwer3>
|
||||
</test_default_entity>
|
||||
XML
|
||||
Entities::TestDefaultEntity.from_xml(Nokogiri::XML(<<~XML).root)
|
||||
<test_default_entity>
|
||||
<test1>asdf</test1>
|
||||
<test2>qwer</qwer2>
|
||||
<test3>true</qwer3>
|
||||
</test_default_entity>
|
||||
XML
|
||||
end
|
||||
|
||||
it "forms .from_hash arguments basing on parse return array" do
|
||||
|
|
@ -286,38 +286,38 @@ XML
|
|||
describe ".from_json" do
|
||||
it "parses entity properties from the input JSON data" do
|
||||
now = change_time(Time.now.utc)
|
||||
entity_data = <<-JSON
|
||||
{
|
||||
"entity_type": "test_complex_entity",
|
||||
"entity_data": {
|
||||
"test1": "abc",
|
||||
"test2": false,
|
||||
"test3": "def",
|
||||
"test4": 123,
|
||||
"test5": "#{now.iso8601}",
|
||||
"test6": {
|
||||
"entity_type": "test_entity",
|
||||
"entity_data": {
|
||||
"test": "nested"
|
||||
}
|
||||
},
|
||||
"multi": [
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "02"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
entity_data = <<~JSON
|
||||
{
|
||||
"entity_type": "test_complex_entity",
|
||||
"entity_data": {
|
||||
"test1": "abc",
|
||||
"test2": false,
|
||||
"test3": "def",
|
||||
"test4": 123,
|
||||
"test5": "#{now.iso8601}",
|
||||
"test6": {
|
||||
"entity_type": "test_entity",
|
||||
"entity_data": {
|
||||
"test": "nested"
|
||||
}
|
||||
},
|
||||
"multi": [
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "02"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
entity = Entities::TestComplexEntity.from_json(JSON.parse(entity_data))
|
||||
expect(entity).to be_an_instance_of(Entities::TestComplexEntity)
|
||||
|
|
@ -513,13 +513,13 @@ JSON
|
|||
end
|
||||
|
||||
it "handles empty xml-element for nested entities" do
|
||||
xml = <<-XML
|
||||
<test_nested_entity>
|
||||
<asdf>FDSA</asdf>
|
||||
<test_entity/>
|
||||
<other_entity/>
|
||||
</test_nested_entity>
|
||||
XML
|
||||
xml = <<~XML
|
||||
<test_nested_entity>
|
||||
<asdf>FDSA</asdf>
|
||||
<test_entity/>
|
||||
<other_entity/>
|
||||
</test_nested_entity>
|
||||
XML
|
||||
|
||||
entity = Entities::TestNestedEntity.from_xml(Nokogiri::XML(xml).root)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ module DiasporaFederation
|
|||
|
||||
it "raises error when the entity class doesn't match the entity_type property" do
|
||||
expect {
|
||||
json_parser.parse(JSON.parse(<<-JSON
|
||||
{
|
||||
"entity_type": "unknown_entity",
|
||||
"entity_data": {}
|
||||
}
|
||||
JSON
|
||||
json_parser.parse(JSON.parse(<<~JSON
|
||||
{
|
||||
"entity_type": "unknown_entity",
|
||||
"entity_data": {}
|
||||
}
|
||||
JSON
|
||||
))
|
||||
}.to raise_error DiasporaFederation::Parsers::BaseParser::InvalidRootNode,
|
||||
"'unknown_entity' can't be parsed by #{entity_class}"
|
||||
|
|
@ -29,38 +29,38 @@ JSON
|
|||
|
||||
it "returns a hash for the correct JSON input" do
|
||||
now = change_time(Time.now.utc)
|
||||
json = <<-JSON
|
||||
{
|
||||
"entity_type": "test_complex_entity",
|
||||
"entity_data": {
|
||||
"test1": "abc",
|
||||
"test2": false,
|
||||
"test3": "def",
|
||||
"test4": 123,
|
||||
"test5": "#{now.iso8601}",
|
||||
"test6": {
|
||||
"entity_type": "test_entity",
|
||||
"entity_data": {
|
||||
"test": "nested"
|
||||
}
|
||||
},
|
||||
"multi": [
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "02"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
json = <<~JSON
|
||||
{
|
||||
"entity_type": "test_complex_entity",
|
||||
"entity_data": {
|
||||
"test1": "abc",
|
||||
"test2": false,
|
||||
"test3": "def",
|
||||
"test4": 123,
|
||||
"test5": "#{now.iso8601}",
|
||||
"test6": {
|
||||
"entity_type": "test_entity",
|
||||
"entity_data": {
|
||||
"test": "nested"
|
||||
}
|
||||
},
|
||||
"multi": [
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity_type": "other_entity",
|
||||
"entity_data": {
|
||||
"asdf": "02"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
hash = json_parser.parse(JSON.parse(json)).first
|
||||
expect(hash).to be_a(Hash)
|
||||
expect(hash[:test1]).to eq("abc")
|
||||
|
|
@ -77,17 +77,17 @@ JSON
|
|||
end
|
||||
|
||||
it "doesn't drop extra properties" do
|
||||
json = <<-JSON.strip
|
||||
{
|
||||
"entity_type": "test_default_entity",
|
||||
"entity_data": {
|
||||
"test1": "abc",
|
||||
"test2": false,
|
||||
"test3": "def",
|
||||
"test_new": "new_value"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
json = <<~JSON.strip
|
||||
{
|
||||
"entity_type": "test_default_entity",
|
||||
"entity_data": {
|
||||
"test1": "abc",
|
||||
"test2": false,
|
||||
"test3": "def",
|
||||
"test_new": "new_value"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
parsed = Parsers::JsonParser.new(Entities::TestDefaultEntity).parse(JSON.parse(json))
|
||||
expect(parsed[0]["test_new"]).to eq("new_value")
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@ module DiasporaFederation
|
|||
'{"entity_type": "some_relayable", "entity_data": {}}'
|
||||
|
||||
it "returns property order as a second argument" do
|
||||
json = JSON.parse <<-JSON
|
||||
{
|
||||
"entity_type": "some_relayable",
|
||||
"property_order": ["property", "guid", "author"],
|
||||
"entity_data": {
|
||||
"author": "id@example.tld",
|
||||
"guid": "im a guid",
|
||||
"property": "value"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
json = JSON.parse <<~JSON
|
||||
{
|
||||
"entity_type": "some_relayable",
|
||||
"property_order": ["property", "guid", "author"],
|
||||
"entity_data": {
|
||||
"author": "id@example.tld",
|
||||
"guid": "im a guid",
|
||||
"property": "value"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
parsed_data = json_parser.parse(json)
|
||||
expect(parsed_data[0]).to be_a(Hash)
|
||||
expect(parsed_data[0][:guid]).to eq("im a guid")
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ module DiasporaFederation
|
|||
let(:entity_class) { Entities::SomeRelayable }
|
||||
let(:xml_parser) { Parsers::RelayableXmlParser.new(entity_class) }
|
||||
it "passes order of the XML elements as a second argument in the returned list" do
|
||||
xml_object = Nokogiri::XML(<<-XML).root
|
||||
<some_relayable>
|
||||
<guid>im a guid</guid>
|
||||
<property>value</property>
|
||||
<author>id@example.tld</author>
|
||||
</some_relayable>
|
||||
XML
|
||||
xml_object = Nokogiri::XML(<<~XML).root
|
||||
<some_relayable>
|
||||
<guid>im a guid</guid>
|
||||
<property>value</property>
|
||||
<author>id@example.tld</author>
|
||||
</some_relayable>
|
||||
XML
|
||||
|
||||
parsed_data = xml_parser.parse(xml_object)
|
||||
expect(parsed_data[0]).to be_a(Hash)
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
it "raises an error when the entity class doesn't match the root node" do
|
||||
xml = <<-XML
|
||||
<unknown_entity>
|
||||
<test>asdf</test>
|
||||
</unknown_entity>
|
||||
XML
|
||||
xml = <<~XML
|
||||
<unknown_entity>
|
||||
<test>asdf</test>
|
||||
</unknown_entity>
|
||||
XML
|
||||
|
||||
expect {
|
||||
xml_parser.parse(Nokogiri::XML(xml).root)
|
||||
|
|
@ -34,12 +34,12 @@ XML
|
|||
end
|
||||
|
||||
it "uses xml_name for parsing" do
|
||||
xml = <<-XML.strip
|
||||
<test_entity_with_xml_name>
|
||||
<test>asdf</test>
|
||||
<asdf>qwer</asdf>
|
||||
</test_entity_with_xml_name>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_entity_with_xml_name>
|
||||
<test>asdf</test>
|
||||
<asdf>qwer</asdf>
|
||||
</test_entity_with_xml_name>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestEntityWithXmlName).parse(Nokogiri::XML(xml).root)
|
||||
|
||||
|
|
@ -48,12 +48,12 @@ XML
|
|||
end
|
||||
|
||||
it "allows name for parsing even when property has a xml_name" do
|
||||
xml = <<-XML.strip
|
||||
<test_entity_with_xml_name>
|
||||
<test>asdf</test>
|
||||
<qwer>qwer</qwer>
|
||||
</test_entity_with_xml_name>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_entity_with_xml_name>
|
||||
<test>asdf</test>
|
||||
<qwer>qwer</qwer>
|
||||
</test_entity_with_xml_name>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestEntityWithXmlName).parse(Nokogiri::XML(xml).root)
|
||||
|
||||
|
|
@ -62,13 +62,13 @@ XML
|
|||
end
|
||||
|
||||
it "parses the string to the correct type" do
|
||||
xml = <<-XML.strip
|
||||
<test_default_entity>
|
||||
<test1>asdf</test1>
|
||||
<test2>qwer</qwer2>
|
||||
<test3>true</qwer3>
|
||||
</test_default_entity>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_default_entity>
|
||||
<test1>asdf</test1>
|
||||
<test2>qwer</qwer2>
|
||||
<test3>true</qwer3>
|
||||
</test_default_entity>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestDefaultEntity).parse(Nokogiri::XML(xml).root)
|
||||
|
||||
|
|
@ -78,11 +78,11 @@ XML
|
|||
end
|
||||
|
||||
it "parses boolean fields with false value" do
|
||||
xml = <<-XML.strip
|
||||
<test_entity_with_boolean>
|
||||
<test>false</test>
|
||||
</test_entity_with_boolean>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_entity_with_boolean>
|
||||
<test>false</test>
|
||||
</test_entity_with_boolean>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestEntityWithBoolean).parse(Nokogiri::XML(xml).root)
|
||||
expect(parsed[0][:test]).to eq(false)
|
||||
|
|
@ -90,11 +90,11 @@ XML
|
|||
|
||||
it "parses boolean fields with a randomly matching pattern as nil" do
|
||||
%w[ttFFFtt yesFFDSFSDy noDFDSFFDFn fXf LLyes].each do |weird_value|
|
||||
xml = <<-XML.strip
|
||||
<test_entity_with_boolean>
|
||||
<test>#{weird_value}</test>
|
||||
</test_entity_with_boolean>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_entity_with_boolean>
|
||||
<test>#{weird_value}</test>
|
||||
</test_entity_with_boolean>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestEntityWithBoolean).parse(
|
||||
Nokogiri::XML(xml).root
|
||||
|
|
@ -105,11 +105,11 @@ XML
|
|||
|
||||
it "parses integer fields with a randomly matching pattern as nil" do
|
||||
%w[1,2,3 foobar two].each do |weird_value|
|
||||
xml = <<-XML.strip
|
||||
<test_entity_with_integer>
|
||||
<test>#{weird_value}</test>
|
||||
</test_entity_with_integer>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_entity_with_integer>
|
||||
<test>#{weird_value}</test>
|
||||
</test_entity_with_integer>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestEntityWithInteger).parse(
|
||||
Nokogiri::XML(xml).root
|
||||
|
|
@ -120,11 +120,11 @@ XML
|
|||
|
||||
it "parses timestamp fields with a randomly matching pattern as nil" do
|
||||
%w[foobar yesterday now 1.2.foo].each do |weird_value|
|
||||
xml = <<-XML.strip
|
||||
<test_entity_with_timestamp>
|
||||
<test>#{weird_value}</test>
|
||||
</test_entity_with_timestamp>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_entity_with_timestamp>
|
||||
<test>#{weird_value}</test>
|
||||
</test_entity_with_timestamp>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestEntityWithTimestamp).parse(
|
||||
Nokogiri::XML(xml).root
|
||||
|
|
@ -154,14 +154,14 @@ XML
|
|||
end
|
||||
|
||||
it "doesn't drop extra properties" do
|
||||
xml = <<-XML.strip
|
||||
<test_default_entity>
|
||||
<test1>asdf</test1>
|
||||
<test2>qwer</test2>
|
||||
<test3>true</test3>
|
||||
<test_new>new_value</test_new>
|
||||
</test_default_entity>
|
||||
XML
|
||||
xml = <<~XML.strip
|
||||
<test_default_entity>
|
||||
<test1>asdf</test1>
|
||||
<test2>qwer</test2>
|
||||
<test3>true</test3>
|
||||
<test_new>new_value</test_new>
|
||||
</test_default_entity>
|
||||
XML
|
||||
|
||||
parsed = Parsers::XmlParser.new(Entities::TestDefaultEntity).parse(Nokogiri::XML(xml).root)
|
||||
expect(parsed[0]["test_new"]).to eq("new_value")
|
||||
|
|
|
|||
|
|
@ -27,21 +27,21 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
it "verifies the existence of 'encrypted_header'" do
|
||||
faulty_xml = <<XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
</diaspora>
|
||||
XML
|
||||
faulty_xml = <<~XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
</diaspora>
|
||||
XML
|
||||
expect {
|
||||
Salmon::EncryptedSlap.from_xml(faulty_xml, recipient_key)
|
||||
}.to raise_error Salmon::MissingHeader
|
||||
end
|
||||
|
||||
it "verifies the existence of a magic envelope" do
|
||||
faulty_xml = <<XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
<encrypted_header/>
|
||||
</diaspora>
|
||||
XML
|
||||
faulty_xml = <<~XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
<encrypted_header/>
|
||||
</diaspora>
|
||||
XML
|
||||
expect(Salmon::EncryptedSlap).to receive(:header_data).and_return(aes_key: "", iv: "", author_id: "")
|
||||
expect {
|
||||
Salmon::EncryptedSlap.from_xml(faulty_xml, recipient_key)
|
||||
|
|
|
|||
|
|
@ -26,24 +26,24 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
it "verifies the existence of an author_id" do
|
||||
faulty_xml = <<XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
<header/>
|
||||
</diaspora>
|
||||
XML
|
||||
faulty_xml = <<~XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
<header/>
|
||||
</diaspora>
|
||||
XML
|
||||
expect {
|
||||
Salmon::Slap.from_xml(faulty_xml)
|
||||
}.to raise_error Salmon::MissingAuthor
|
||||
end
|
||||
|
||||
it "verifies the existence of a magic envelope" do
|
||||
faulty_xml = <<-XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
<header>
|
||||
<author_id>#{sender}</author_id>
|
||||
</header>
|
||||
</diaspora>
|
||||
XML
|
||||
faulty_xml = <<~XML
|
||||
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
|
||||
<header>
|
||||
<author_id>#{sender}</author_id>
|
||||
</header>
|
||||
</diaspora>
|
||||
XML
|
||||
expect {
|
||||
Salmon::Slap.from_xml(faulty_xml)
|
||||
}.to raise_error Salmon::MissingMagicEnvelope
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
module DiasporaFederation
|
||||
describe Salmon::XmlPayload do
|
||||
let(:entity) { Entities::TestEntity.new(test: "asdf") }
|
||||
let(:entity_xml) { <<-XML.strip }
|
||||
<XML>
|
||||
<post>
|
||||
<test_entity>
|
||||
<test>asdf</test>
|
||||
</test_entity>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
let(:entity_xml) { <<~XML.strip }
|
||||
<XML>
|
||||
<post>
|
||||
<test_entity>
|
||||
<test>asdf</test>
|
||||
</test_entity>
|
||||
</post>
|
||||
</XML>
|
||||
XML
|
||||
|
||||
describe ".unpack" do
|
||||
context "sanity" do
|
||||
|
|
@ -43,11 +43,11 @@ XML
|
|||
end
|
||||
|
||||
it "allows unwrapped entities" do
|
||||
xml = <<-XML
|
||||
<test_entity>
|
||||
<test>asdf</test>
|
||||
</test_entity>
|
||||
XML
|
||||
xml = <<~XML
|
||||
<test_entity>
|
||||
<test>asdf</test>
|
||||
</test_entity>
|
||||
XML
|
||||
|
||||
entity = Salmon::XmlPayload.unpack(Nokogiri::XML(xml).root)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue