ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/go/pkg/mod/github.com/aws/[email protected]/awstesting/assert_test.go
package awstesting_test

import (
	"encoding/xml"
	"testing"

	"github.com/aws/aws-sdk-go/awstesting"
)

func TestAssertJSON(t *testing.T) {
	cases := []struct {
		e, a    string
		asserts bool
	}{
		{
			e:       `{"RecursiveStruct":{"RecursiveMap":{"foo":{"NoRecurse":"foo"},"bar":{"NoRecurse":"bar"}}}}`,
			a:       `{"RecursiveStruct":{"RecursiveMap":{"bar":{"NoRecurse":"bar"},"foo":{"NoRecurse":"foo"}}}}`,
			asserts: true,
		},
	}

	for i, c := range cases {
		mockT := &testing.T{}
		if awstesting.AssertJSON(mockT, c.e, c.a) != c.asserts {
			t.Error("Assert JSON result was not expected.", i)
		}
	}
}

func TestAssertXML(t *testing.T) {
	cases := []struct {
		e, a      string
		asserts   bool
		container struct {
			XMLName         xml.Name `xml:"OperationRequest"`
			NS              string   `xml:"xmlns,attr"`
			RecursiveStruct struct {
				XMLName      xml.Name
				RecursiveMap struct {
					XMLName xml.Name
					Entries []struct {
						Key   string `xml:"key"`
						Value struct {
							XMLName   xml.Name `xml:"value"`
							NoRecurse string
						}
					} `xml:"entry"`
				}
			}
		}
	}{
		{
			e:       `<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveMap xmlns="https://foo/"><entry xmlns="https://foo/"><key xmlns="https://foo/">foo</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></value></entry><entry xmlns="https://foo/"><key xmlns="https://foo/">bar</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">bar</NoRecurse></value></entry></RecursiveMap></RecursiveStruct></OperationRequest>`,
			a:       `<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveMap xmlns="https://foo/"><entry xmlns="https://foo/"><key xmlns="https://foo/">foo</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></value></entry><entry xmlns="https://foo/"><key xmlns="https://foo/">bar</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">bar</NoRecurse></value></entry></RecursiveMap></RecursiveStruct></OperationRequest>`,
			asserts: true,
		},
		{
			e:       `<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveMap xmlns="https://foo/"><entry xmlns="https://foo/"><key xmlns="https://foo/">foo</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">foo</NoRecurse></value></entry><entry xmlns="https://foo/"><key xmlns="https://foo/">bar</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">bar</NoRecurse></value></entry></RecursiveMap></RecursiveStruct></OperationRequest>`,
			a:       `<OperationRequest xmlns="https://foo/"><RecursiveStruct xmlns="https://foo/"><RecursiveMap xmlns="https://foo/"><entry xmlns="https://foo/"><key xmlns="https://foo/">baz</key><value xmlns="https://foo/"><NoRecurse xmlns="https://foo/">baz</NoRecurse></value></entry></RecursiveMap></RecursiveStruct></OperationRequest>`,
			asserts: false,
		},
	}

	for i, c := range cases {
		mockT := &testing.T{}
		if awstesting.AssertXML(mockT, c.e, c.a) != c.asserts {
			t.Error("Assert XML result was not expected.", i)
		}
	}
}

func TestAssertQuery(t *testing.T) {
	cases := []struct {
		e, a    string
		asserts bool
	}{
		{
			e:       `Action=OperationName&Version=2014-01-01&Foo=val1&Bar=val2`,
			a:       `Action=OperationName&Version=2014-01-01&Foo=val2&Bar=val3`,
			asserts: false,
		},
		{
			e:       `Action=OperationName&Version=2014-01-01&Foo=val1&Bar=val2`,
			a:       `Action=OperationName&Version=2014-01-01&Foo=val1&Bar=val2`,
			asserts: true,
		},
	}

	for i, c := range cases {
		mockT := &testing.T{}
		if awstesting.AssertQuery(mockT, c.e, c.a) != c.asserts {
			t.Error("Assert Query result was not expected.", i)
		}
	}
}