forked from jshiffer/go-xmpp
Fix missing entry in payload registry
This commit is contained in:
parent
45cb2e6f34
commit
322a6594e7
18
iq.go
18
iq.go
@ -317,13 +317,6 @@ type DiscoItem struct {
|
|||||||
Node string `xml:"node,attr,omitempty"`
|
Node string `xml:"node,attr,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
TypeRegistry.MapExtension(PKTIQ, xml.Name{NSDiscoInfo, "query"}, DiscoInfo{})
|
|
||||||
TypeRegistry.MapExtension(PKTIQ, xml.Name{NSDiscoItems, "query"}, DiscoItems{})
|
|
||||||
TypeRegistry.MapExtension(PKTIQ, xml.Name{"urn:ietf:params:xml:ns:xmpp-bind", "bind"}, BindBind{})
|
|
||||||
TypeRegistry.MapExtension(PKTIQ, xml.Name{"urn:xmpp:iot:control", "set"}, ControlSet{})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Software Version (XEP-0092)
|
// Software Version (XEP-0092)
|
||||||
|
|
||||||
@ -335,3 +328,14 @@ type Version struct {
|
|||||||
Version string `xml:"version,omitempty"`
|
Version string `xml:"version,omitempty"`
|
||||||
OS string `xml:"os,omitempty"`
|
OS string `xml:"os,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Registry init
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
TypeRegistry.MapExtension(PKTIQ, xml.Name{NSDiscoInfo, "query"}, DiscoInfo{})
|
||||||
|
TypeRegistry.MapExtension(PKTIQ, xml.Name{NSDiscoItems, "query"}, DiscoItems{})
|
||||||
|
TypeRegistry.MapExtension(PKTIQ, xml.Name{"urn:ietf:params:xml:ns:xmpp-bind", "bind"}, BindBind{})
|
||||||
|
TypeRegistry.MapExtension(PKTIQ, xml.Name{"urn:xmpp:iot:control", "set"}, ControlSet{})
|
||||||
|
TypeRegistry.MapExtension(PKTIQ, xml.Name{"jabber:iq:version", "query"}, Version{})
|
||||||
|
}
|
||||||
|
16
iq_test.go
16
iq_test.go
@ -1,4 +1,4 @@
|
|||||||
package xmpp_test // import "gosrc.io/xmpp"
|
package xmpp_test // import "gosrc.io/xmpp_test"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
@ -113,3 +113,17 @@ func TestDiscoItems(t *testing.T) {
|
|||||||
t.Errorf("non matching items\n%s", cmp.Diff(parsedIQ.Payload, iq.Payload))
|
t.Errorf("non matching items\n%s", cmp.Diff(parsedIQ.Payload, iq.Payload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUnmarshalPayload(t *testing.T) {
|
||||||
|
query := "<iq to='service.localhost' type='get' id='1'><query xmlns='jabber:iq:version'/></iq>"
|
||||||
|
|
||||||
|
parsedIQ := xmpp.IQ{}
|
||||||
|
err := xml.Unmarshal([]byte(query), &parsedIQ)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unmarshal(%s) returned error", query)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(parsedIQ.Payload) != 1 {
|
||||||
|
t.Errorf("Incorrect payload size: %d", len(parsedIQ.Payload))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user