Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failing test and added testing artifact to ignore #268

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ myservice
build
.DS_Store
dist
.idea/
.idea/
fixtures/epcis/epcisquery_gen.src
**/cover.out
**/cover.html
4 changes: 3 additions & 1 deletion fixtures/epcis/epcisquery.src
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ type Partner struct {
}

type PartnerIdentification struct {
XMLName xml.Name `xml:"http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader Identifier"`

Value string `xml:",chardata" json:"-,"`

Authority string `xml:"Authority,attr,omitempty" json:"Authority,omitempty"`
Authority string `xml:"http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader Authority,attr,omitempty" json:"Authority,omitempty"`
}

type ContactInformation struct {
Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module github.com/hooklift/gowsdl
module github.com/jordanweschler/gowsdl

go 1.15

require github.com/stretchr/testify v1.6.1
require (
github.com/stretchr/testify v1.6.1
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect
)
34 changes: 34 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.5.1-0.20230111220935-a7f7db3f17fc h1:zRn9MzwG18RZhyanShCfUwJTcobvqw8fOjjROFN9jtM=
golang.org/x/tools v0.5.1-0.20230111220935-a7f7db3f17fc/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
golang.org/x/tools/cmd/cover v0.1.0-deprecated h1:Rwy+mWYz6loAF+LnG1jHG/JWMHRMMC2/1XX3Ejkx9lA=
golang.org/x/tools/cmd/cover v0.1.0-deprecated/go.mod h1:hMDiIvlpN1NoVgmjLjUJE9tMHyxHjFX7RuQ+rW12mSA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
7 changes: 4 additions & 3 deletions location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package gowsdl

import (
"fmt"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -88,9 +89,9 @@ func TestLocation_Parse_File(t *testing.T) {
ref string
expected string
}{
{"fixtures/test.wsdl", "some.xsd", "fixtures/some.xsd"},
{"fixtures/test.wsdl", "../xsd/some.xsd", "xsd/some.xsd"},
{"fixtures/test.wsdl", "xsd/some.xsd", "fixtures/xsd/some.xsd"},
{"fixtures/test.wsdl", "some.xsd", fmt.Sprintf("fixtures%csome.xsd", os.PathSeparator)},
{"fixtures/test.wsdl", "../xsd/some.xsd", fmt.Sprintf("xsd%csome.xsd", os.PathSeparator)},
{"fixtures/test.wsdl", "xsd/some.xsd", fmt.Sprintf("fixtures%cxsd%csome.xsd", os.PathSeparator, os.PathSeparator)},
}
for _, test := range tests {
r, err := ParseLocation(test.name)
Expand Down
11 changes: 11 additions & 0 deletions soap/soap.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ type options struct {
httpHeaders map[string]string
mtom bool
mma bool
reqLogger func(s string) ()
}

var defaultOptions = options{
Expand Down Expand Up @@ -329,6 +330,12 @@ func WithMIMEMultipartAttachments() Option {
}
}

func WithReqLogger(logger func (s string) ()) Option {
return func(o *options) {
o.reqLogger = logger
}
}

// Client is soap client
type Client struct {
url string
Expand Down Expand Up @@ -447,6 +454,10 @@ func (s *Client) call(ctx context.Context, soapAction string, request, response
return err
}

if s.opts.reqLogger != nil {
s.opts.reqLogger(buffer.String())
}

req, err := http.NewRequest("POST", s.url, buffer)
if err != nil {
return err
Expand Down
9 changes: 8 additions & 1 deletion soap/soap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ func TestClient_Call(t *testing.T) {
}))
defer ts.Close()

client := NewClient(ts.URL)
logger := func (s string) {
wantedReq := `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><Ping xmlns="http://example.com/service.xsd"><request><Message>Hi</Message></request></Ping></soap:Body></soap:Envelope>`
if s != wantedReq {
t.Errorf("created req %s expected %s", s, wantedReq)
}
}

client := NewClient(ts.URL, WithReqLogger(logger))
req := &Ping{Request: &PingRequest{Message: "Hi"}}
reply := &PingResponse{}
if err := client.Call("GetData", req, reply); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions soap/xsdDateTime.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package soap

import (
"encoding/json"
"encoding/xml"
"strings"
"time"
Expand Down Expand Up @@ -185,6 +186,11 @@ func (xd XSDDate) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
return attr, nil
}

func (xd XSDDate) MarshalJSON() ([]byte, error) {
xdString := xd.string()
return json.Marshal(xdString)
}

// returns string representation and skips "zero" time values
func (xd XSDDate) string() string {
if !xd.innerDate.IsZero() {
Expand Down