An IQ can only have a single payload

"An IQ stanza of type "get" or "set" MUST contain exactly one
 child element, which specifies the semantics of the particular
 request."
This commit is contained in:
Mickael Remond
2019-06-19 10:21:57 +02:00
committed by Mickaël Rémond
parent d455f29258
commit af0ae525b8
8 changed files with 23 additions and 29 deletions

View File

@@ -78,18 +78,16 @@ func TestParsingDelegationIQ(t *testing.T) {
// Check that we have extracted the delegation info as IQPayload
var node string
for _, ext := range iq.Payload {
if delegation, ok := ext.(*Delegation); ok {
if iq.Payload != nil {
if delegation, ok := iq.Payload.(*Delegation); ok {
packet := delegation.Forwarded.Stanza
forwardedIQ, ok := packet.(IQ)
if !ok {
t.Errorf("Could not extract packet IQ")
return
}
payload := forwardedIQ.Payload
if len(payload) > 0 {
pl := payload[0]
if pubsub, ok := pl.(*PubSub); ok {
if forwardedIQ.Payload != nil {
if pubsub, ok := forwardedIQ.Payload.(*PubSub); ok {
node = pubsub.Publish.Node
}
}