Merge

Tue, 27 Oct 2015 23:14:19 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 27 Oct 2015 23:14:19 +0000
changeset 46
d711bf1e9979
parent 45
744c81c124b6 (current diff)
parent 38
68458d0c50a0 (diff)
child 47
1cbc0d9d132d

Merge

main.lua file | annotate | diff | comparison | revisions
scansion/objects/client.lua file | annotate | diff | comparison | revisions
--- a/main.lua	Tue Oct 27 23:09:08 2015 +0000
+++ b/main.lua	Tue Oct 27 23:14:19 2015 +0000
@@ -85,8 +85,11 @@
 
 if not ok then
 	print("TEST ERROR:", result);
+	os.exit(2);
 elseif not result then
 	print("TEST FAILED", err);
+	os.exit(1);
 else
 	print("TEST PASSED");
+	os.exit(0);
 end
--- a/scansion/objects/client.lua	Tue Oct 27 23:09:08 2015 +0000
+++ b/scansion/objects/client.lua	Tue Oct 27 23:14:19 2015 +0000
@@ -7,22 +7,29 @@
 
 local stanzacmp = require "scansion.stanzacmp";
 
+local function filter_expression(script, s)
+	local expr = s:match("^%$%{(.+)%}$");
+	if not expr then return s end
+	local name, value_name = expr:match("^(.+)'s (.+)$");
+	assert(name, "Unable to parse expression: "..expr);
+	local key = value_name:lower():gsub(" ", "_");
+	assert(script.objects[name], "Unknown object called "..name);
+	local value = script.objects[name][key];
+	assert(value ~= nil, "Unknown attribute (of "..name.."): "..value_name);
+	return value;
+end
+
 local function fill_vars(script, stanza)
 	for k, v in pairs(stanza.attr) do
-		local expr = v:match("^%$%{(.+)%}$");
-		if expr then
-			local name, value_name = expr:match("^(.+)'s (.+)$");
-			assert(name, "Unable to parse expression: "..expr);
-			local key = value_name:lower():gsub(" ", "_");
-			assert(script.objects[name], "Unknown object called "..name);
-			local value = script.objects[name][key];
-			assert(value ~= nil, "Unknown attribute (of "..name.."): "..value_name);
-			stanza.attr[k] = value;
+		stanza.attr[k] = filter_expression(script, v);
+	end
+	for i, child in ipairs(stanza) do
+		if type(child) == "string" then
+			stanza[i] = filter_expression(script, child);
+		elseif type(child) == "table" then
+			fill_vars(script, child);
 		end
 	end
-	for _, child in ipairs(stanza.tags) do
-		fill_vars(script, child);
-	end
 	return stanza;
 end
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/pubsub_advanced.scs	Tue Oct 27 23:14:19 2015 +0000
@@ -0,0 +1,158 @@
+[Client] Balthasar
+	jid: admin@localhost
+	password: password
+
+[Client] Romeo
+	jid: romeo@localhost
+	password: password
+
+[Client] Juliet
+	jid: juliet@localhost
+	password: password
+
+---------
+
+Romeo connects
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<create node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="error">
+		<error type="auth">
+			<forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+		</error>
+	</iq>
+
+Balthasar connects
+
+Balthasar sends:
+	<iq type='set' to='pubsub.localhost'>
+		<pubsub xmlns='http://jabber.org/protocol/pubsub'>
+			<create node='princely_musings'/>
+		</pubsub>
+	</iq>
+
+Balthasar receives:
+	<iq type="result"/>
+
+Balthasar sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<create node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Balthasar receives:
+	<iq type="error">
+		<error type="cancel">
+			<conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
+		</error>
+	</iq>
+
+Juliet connects
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<subscribe node="princely_musings" jid="${Romeo's full JID}"/>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="error"/>
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<subscribe node="princely_musings" jid="${Juliet's full JID}"/>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="result"/>
+
+Balthasar sends:
+	<iq type="get">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<affiliations node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Balthasar receives:
+	<iq type="result">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<affiliations node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Balthasar sends:
+	<iq type="set">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<affiliations node="princely_musings">
+				<affiliation jid="bard@shakespeare.lit" affiliation="publisher"/>
+			</affiliations>
+		</pubsub>
+	</iq>
+
+Balthasar receives:
+	<iq type="result"/>
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<publish node="princely_musings">
+				<item id="current">
+					<entry xmlns="http://www.w3.org/2005/Atom">
+						<title>Soliloquy</title>
+						<summary>Lorem ipsum dolor sit amet</summary>
+					</entry>
+				</item>
+			</publish>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<message type="headline" from="pubsub.localhost">
+		<event xmlns="http://jabber.org/protocol/pubsub#event">
+			<items node="princely_musings">
+				<item id="current">
+					<entry xmlns="http://www.w3.org/2005/Atom">
+						<title>Soliloquy</title>
+						<summary>Lorem ipsum dolor sit amet</summary>
+					</entry>
+				</item>
+			</items>
+		</event>
+	</message>
+
+Romeo receives:
+	<iq type="result"/>
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<unsubscribe node="princely_musings" jid="${Juliet's full JID}"/>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="result"/>
+
+Balthasar sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<delete node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Balthasar receives:
+	<iq type="result"/>
+
+Romeo disconnects
+
+// vim: syntax=xml:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/pubsub_basic.scs	Tue Oct 27 23:14:19 2015 +0000
@@ -0,0 +1,102 @@
+[Client] Romeo
+	jid: admin@localhost
+	password: password
+
+// admin@localhost is assumed to have node creation privileges
+
+[Client] Juliet
+	jid: juliet@localhost
+	password: password
+
+---------
+
+Romeo connects
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<create node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result"/>
+
+Juliet connects
+
+-- Juliet sends:
+-- 	<iq type="set" to="pubsub.localhost">
+-- 		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+-- 			<subscribe node="princely_musings" jid="${Romeo's full JID}"/>
+-- 		</pubsub>
+-- 	</iq>
+-- 
+-- Juliet receives:
+-- 	<iq type="error"/>
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<subscribe node="princely_musings" jid="${Juliet's full JID}"/>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="result"/>
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<publish node="princely_musings">
+				<item id="current">
+					<entry xmlns="http://www.w3.org/2005/Atom">
+						<title>Soliloquy</title>
+						<summary>Lorem ipsum dolor sit amet</summary>
+					</entry>
+				</item>
+			</publish>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result"/>
+
+Juliet receives:
+	<message type="headline" from="pubsub.localhost">
+		<event xmlns="http://jabber.org/protocol/pubsub#event">
+			<items node="princely_musings">
+				<item id="current">
+					<entry xmlns="http://www.w3.org/2005/Atom">
+						<title>Soliloquy</title>
+						<summary>Lorem ipsum dolor sit amet</summary>
+					</entry>
+				</item>
+			</items>
+		</event>
+	</message>
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<unsubscribe node="princely_musings" jid="${Juliet's full JID}"/>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="result"/>
+
+Juliet disconnects
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<delete node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result"/>
+
+Romeo disconnects
+
+// vim: syntax=xml:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/pubsub_createdelete.scs	Tue Oct 27 23:14:19 2015 +0000
@@ -0,0 +1,61 @@
+[Client] Romeo
+	jid: admin@localhost
+	password: password
+
+// admin@localhost is assumed to have node creation privileges
+
+---------
+
+Romeo connects
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<create node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result"/>
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<create node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="error">
+		<error type="cancel">
+			<conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
+		</error>
+	</iq>
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<delete node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result"/>
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost">
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<delete node="princely_musings"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="error">
+		<error type="cancel">
+			<item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
+		</error>
+	</iq>
+
+Romeo disconnects
+
+// vim: syntax=xml:

mercurial