Beispiel #1
0
        public void ModifyAffiliations()
        {
            const string XML =
                @"<iq type='set'                
                to='pubsub.shakespeare.lit'
                id='ent3'
                xmlns='jabber:client'>
              <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
                <affiliations node='princely_musings'>
                  <affiliation jid='*****@*****.**' affiliation='none'/>
                  <affiliation jid='*****@*****.**' affiliation='none'/>
                  <affiliation jid='*****@*****.**' affiliation='publisher'/>
                </affiliations>
              </pubsub>
            </iq>";

            var affs = new Matrix.Xmpp.PubSub.Owner.Affiliation[3];

            affs[0] = new Matrix.Xmpp.PubSub.Owner.Affiliation {
                Jid = "*****@*****.**", AffiliationType = AffiliationType.None
            };
            affs[1] = new Matrix.Xmpp.PubSub.Owner.Affiliation {
                Jid = "*****@*****.**", AffiliationType = AffiliationType.None
            };
            affs[2] = new Matrix.Xmpp.PubSub.Owner.Affiliation {
                Jid = "*****@*****.**", AffiliationType = AffiliationType.Publisher
            };

            var iq = PubSubBuilder.ModifyAffiliations("pubsub.shakespeare.lit", "princely_musings", affs);

            iq.Id = "ent3";

            iq.ShouldBe(XML);
        }
Beispiel #2
0
        public void TestPublishItem()
        {
            const string XML = @"<iq type='set'            
            to='pubsub.shakespeare.lit'
            id='publish1'
            xmlns='jabber:client'>
          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
            <publish node='princely_musings'>
              <item>
                <entry xmlns='http://www.w3.org/2005/Atom'>
                  <title>Soliloquy</title>
                  <summary>
        To be, or not to be: that is the question:
        Whether 'tis nobler in the mind to suffer
        The slings and arrows of outrageous fortune,
        Or to take arms against a sea of troubles,
        And by opposing end them?
                  </summary>
                  <link rel='alternate' type='text/html'
                        href='http://denmark.lit/2003/12/13/atom03'/>
                  <id>tag:denmark.lit,2003:entry-32397</id>
                  <published>2003-12-13T18:30:02Z</published>
                  <updated>2003-12-13T18:30:02Z</updated>
                </entry>
              </item>
            </publish>
          </pubsub>
        </iq>";

            const string PAYLOAD1 =
                @"<entry xmlns='http://www.w3.org/2005/Atom'>
                  <title>Soliloquy</title>
                  <summary>
        To be, or not to be: that is the question:
        Whether 'tis nobler in the mind to suffer
        The slings and arrows of outrageous fortune,
        Or to take arms against a sea of troubles,
        And by opposing end them?
                  </summary>
                  <link rel='alternate' type='text/html'
                        href='http://denmark.lit/2003/12/13/atom03'/>
                  <id>tag:denmark.lit,2003:entry-32397</id>
                  <published>2003-12-13T18:30:02Z</published>
                  <updated>2003-12-13T18:30:02Z</updated>
                </entry>";

            var payload = XmppXElement.LoadXml(PAYLOAD1);

            var item = new Item();

            item.Add(payload);

            Iq iq = PubSubBuilder.PublishItems("pubsub.shakespeare.lit", "princely_musings", new[] { item });

            iq.Id = "publish1";

            iq.ShouldBe(XML);
        }
Beispiel #3
0
        public void TestCreateNode2()
        {
            const string XML =
                @"<iq type='set'
                    to='pubsub.shakespeare.lit'
                    id='create2'
                    xmlns='jabber:client'>
                    <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                      <create node='princely_musings'/>
                      <configure>
                        <x xmlns='jabber:x:data' type='submit'>
                          <field var='FORM_TYPE' type='hidden'>
                            <value>http://jabber.org/protocol/pubsub#node_config</value>
                          </field>
                          <field var='pubsub#access_model'><value>whitelist</value></field>
                        </x>
                      </configure>
                    </pubsub>
                </iq>";


            var form = new Data {
                Type = FormType.Submit
            };

            var field1 = form.AddField(new Field {
                Type = FieldType.Hidden, Var = "FORM_TYPE"
            });

            field1.SetValue("http://jabber.org/protocol/pubsub#node_config");

            var field2 = form.AddField(new Field {
                Var = "pubsub#access_model"
            });

            field2.SetValue("whitelist");

            var conf = new Configure {
                XData = form
            };

            Iq iq = PubSubBuilder.CreateNode("pubsub.shakespeare.lit", "princely_musings", conf);

            iq.Id = "create2";

            iq.ShouldBe(XML);
        }
Beispiel #4
0
        public void TestPurgeNode()
        {
            const string XML = @"<iq type='set'                
                to='pubsub.shakespeare.lit'
                id='purge1'
                xmlns='jabber:client'>
              <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
                <purge node='blogs/princely_musings'/>
              </pubsub>
            </iq>";

            var iq = PubSubBuilder.PurgeNode("pubsub.shakespeare.lit", "blogs/princely_musings");

            iq.Id = "purge1";

            iq.ShouldBe(XML);
        }
Beispiel #5
0
        public void TestCreateNode()
        {
            const string XML = @"<iq type='set'
                    to='pubsub.shakespeare.lit'
                    id='create1'
                    xmlns='jabber:client'>
                    <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                      <create node='princely_musings'/>
                      <configure/>
                    </pubsub>
                </iq>";

            Iq iq = PubSubBuilder.CreateNode("pubsub.shakespeare.lit", "princely_musings", null);

            iq.Id = "create1";

            iq.ShouldBe(XML);
        }
Beispiel #6
0
        public void RequestAllSubscriptionsStanzaTest()
        {
            const string XML =
                @"<iq type='get'                
                to='pubsub.shakespeare.lit'
                id='ent3'
                xmlns='jabber:client'>
               <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                <subscriptions/>
              </pubsub>
            </iq>";

            var iq = PubSubBuilder.RequestAllSubscriptions("pubsub.shakespeare.lit");

            iq.Id = "ent3";

            iq.ShouldBe(XML);
        }
Beispiel #7
0
        public void TestRequestSubscriptionsList()
        {
            const string XML =
                @"<iq type='get'                   
                    to='pubsub.shakespeare.lit'
                    id='subman1'
                    xmlns='jabber:client'>
                  <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
                    <subscriptions node='princely_musings'/>
                  </pubsub>
                </iq>";

            var iq = PubSubBuilder.RequestSubscriptionsList("pubsub.shakespeare.lit", "princely_musings");

            iq.Id = "subman1";

            iq.ShouldBe(XML);
        }
Beispiel #8
0
        public void TestCreateInstantNode()
        {
            const string XML =
                @"<iq type='set'            
                    to='pubsub.shakespeare.lit'
                    id='instant2'
                    xmlns='jabber:client'>
                    <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                      <create/>
                      <configure/>
                    </pubsub>
                </iq>";

            Iq iq = PubSubBuilder.CreateInstantNode("pubsub.shakespeare.lit");

            iq.Id = "instant2";

            iq.ShouldBe(XML);
        }
Beispiel #9
0
        public void RequestPubsubItemTest()
        {
            const string XML =
                @"<iq type='get'
                    to='pubsub.shakespeare.lit'
                    id='retrieve1'
                    xmlns='jabber:client'>
                  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                    <items node='urn:xmpp:avatar:data'>
                      <item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'/>
                    </items>
                  </pubsub>
                </iq>";

            var iq = PubSubBuilder.RequestItem("pubsub.shakespeare.lit", Namespaces.AvatarData, "111f4b3c50d7b0df729d299bc6f8e9ef9066971f");

            iq.Id = "retrieve1";

            iq.ShouldBe(XML);
        }
Beispiel #10
0
        public void TestCreateNodeConfigurationStanza()
        {
            const string XML =
                @"<iq type='get'
                from='[email protected]/elsinore'
                to='pubsub.shakespeare.lit'
                id='config1'
                xmlns='jabber:client'>
              <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
                <configure node='princely_musings'/>
              </pubsub>
            </iq>";

            var iq = PubSubBuilder.RequestNodeConfiguration("pubsub.shakespeare.lit", "princely_musings");

            iq.Id   = "config1";
            iq.From = "[email protected]/elsinore";

            iq.ShouldBe(XML);
        }
Beispiel #11
0
        public void TestRetractItem()
        {
            const string XML =
                @"<iq type='set'                
                to='pubsub.shakespeare.lit'
                id='retract1'
                xmlns='jabber:client'>
              <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                <retract node='princely_musings'>
                  <item id='ae890ac52d0df67ed7cfdf51b644e901'/>
                </retract>
              </pubsub>
            </iq>";

            var iq = PubSubBuilder.RetractItems("pubsub.shakespeare.lit", "princely_musings", new[] { "ae890ac52d0df67ed7cfdf51b644e901" });

            iq.Id = "retract1";

            iq.ShouldBe(XML);
        }
Beispiel #12
0
        public void TestSubscribe()
        {
            const string XML =
                @" <iq type='set'            
            to='pubsub.shakespeare.lit'
            id='sub1'
            xmlns='jabber:client'>
          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
            <subscribe
                node='princely_musings'
                jid='*****@*****.**'/>
          </pubsub>
        </iq>";

            Iq iq = PubSubBuilder.Subscribe("pubsub.shakespeare.lit", "princely_musings", "*****@*****.**");

            iq.Id = "sub1";

            iq.ShouldBe(XML);
        }
Beispiel #13
0
        public void TestUnsubscribeWithSubId()
        {
            const string XML =
                @"<iq type='set'            
            to='pubsub.shakespeare.lit'
            id='unsub1'
            xmlns='jabber:client'>
          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
             <unsubscribe
                 node='princely_musings'
                 jid='*****@*****.**'
                subid='n1gbwYqLQyH4ILW71fVrk19MJATXnnqna0Wl0PpY'/>
          </pubsub>
        </iq>";

            Iq iq = PubSubBuilder.Unsubscribe("pubsub.shakespeare.lit", "princely_musings", "n1gbwYqLQyH4ILW71fVrk19MJATXnnqna0Wl0PpY", "*****@*****.**");

            iq.Id = "unsub1";

            iq.ShouldBe(XML);
        }
Beispiel #14
0
        public void TestSubmitNodeConfigurationStanza()
        {
            const string XML1 = @"<iq type='set'
            from='[email protected]/elsinore'
            to='pubsub.shakespeare.lit'
            id='config2'
            xmlns='jabber:client'>
              <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
                <configure node='princely_musings'>
                  <x xmlns='jabber:x:data' type='submit'>
                    <field var='FORM_TYPE' type='hidden'>
                      <value>http://jabber.org/protocol/pubsub#node_config</value>
                    </field>
                    <field var='pubsub#title'><value>Princely Musings (Atom)</value></field>
                    <field var='pubsub#deliver_notifications'><value>1</value></field>
                    <field var='pubsub#deliver_payloads'><value>1</value></field>
                    <field var='pubsub#persist_items'><value>1</value></field>
                    <field var='pubsub#max_items'><value>10</value></field>
                    <field var='pubsub#access_model'><value>open</value></field>
                    <field var='pubsub#publish_model'><value>publishers</value></field>
                    <field var='pubsub#send_last_published_item'><value>never</value></field>
                    <field var='pubsub#presence_based_delivery'><value>false</value></field>
                    <field var='pubsub#notify_config'><value>0</value></field>
                    <field var='pubsub#notify_delete'><value>0</value></field>
                    <field var='pubsub#notify_retract'><value>0</value></field>
                    <field var='pubsub#notify_sub'><value>0</value></field>
                    <field var='pubsub#max_payload_size'><value>1028</value></field>
                    <field var='pubsub#type'><value>http://www.w3.org/2005/Atom</value></field>
                    <field var='pubsub#body_xslt'>
                      <value>http://jabxslt.jabberstudio.org/atom_body.xslt</value>
                    </field>
                  </x>
                </configure>
              </pubsub>
            </iq>";

            const string XML2 = @"<x xmlns='jabber:x:data' type='submit'>
                <field var='FORM_TYPE' type='hidden'>
                  <value>http://jabber.org/protocol/pubsub#node_config</value>
                </field>
                <field var='pubsub#title'><value>Princely Musings (Atom)</value></field>
                <field var='pubsub#deliver_notifications'><value>1</value></field>
                <field var='pubsub#deliver_payloads'><value>1</value></field>
                <field var='pubsub#persist_items'><value>1</value></field>
                <field var='pubsub#max_items'><value>10</value></field>
                <field var='pubsub#access_model'><value>open</value></field>
                <field var='pubsub#publish_model'><value>publishers</value></field>
                <field var='pubsub#send_last_published_item'><value>never</value></field>
                <field var='pubsub#presence_based_delivery'><value>false</value></field>
                <field var='pubsub#notify_config'><value>0</value></field>
                <field var='pubsub#notify_delete'><value>0</value></field>
                <field var='pubsub#notify_retract'><value>0</value></field>
                <field var='pubsub#notify_sub'><value>0</value></field>
                <field var='pubsub#max_payload_size'><value>1028</value></field>
                <field var='pubsub#type'><value>http://www.w3.org/2005/Atom</value></field>
                <field var='pubsub#body_xslt'>
                  <value>http://jabxslt.jabberstudio.org/atom_body.xslt</value>
                </field>
              </x>";

            var form = XmppXElement.LoadXml(XML2) as Data;

            var iq = PubSubBuilder.SubmitNodeConfiguration("pubsub.shakespeare.lit", "princely_musings", form);

            iq.Id   = "config2";
            iq.From = "[email protected]/elsinore";

            iq.ShouldBe(XML1);
        }