@@ -17,7 +17,6 @@ import (
1717 "time"
1818
1919 "github.com/docker/go-plugins-helpers/sdk"
20- "github.com/stretchr/testify/require"
2120)
2221
2322type TestPlugin struct {
@@ -150,21 +149,29 @@ func TestPeerCertificateMarshalJSON(t *testing.T) {
150149 }
151150 // generate private key
152151 privatekey , err := rsa .GenerateKey (rand .Reader , 2048 )
153- require .NoError (t , err )
152+ if err != nil {
153+ t .Fatal (err )
154+ }
154155 publickey := & privatekey .PublicKey
155156
156157 // create a self-signed certificate. template = parent
157158 parent := template
158159 raw , err := x509 .CreateCertificate (rand .Reader , template , parent , publickey , privatekey )
159- require .NoError (t , err )
160+ if err != nil {
161+ t .Fatal (err )
162+ }
160163
161164 cert , err := x509 .ParseCertificate (raw )
162- require .NoError (t , err )
165+ if err != nil {
166+ t .Fatal (err )
167+ }
163168
164169 certs := []* x509.Certificate {cert }
165170 addr := "www.authz.com/auth"
166171 req , err := http .NewRequest ("GET" , addr , nil )
167- require .NoError (t , err )
172+ if err != nil {
173+ t .Fatal (err )
174+ }
168175
169176 req .RequestURI = addr
170177 req .TLS = & tls.ConnectionState {}
@@ -176,15 +183,25 @@ func TestPeerCertificateMarshalJSON(t *testing.T) {
176183
177184 t .Run ("Marshalling :" , func (t * testing.T ) {
178185 raw , err = pcObj .MarshalJSON ()
179- require .NotNil (t , raw )
180- require .Nil (t , err )
186+ if raw == nil {
187+ t .Fatalf ("Failed to marshal peer certificate" )
188+ }
189+ if err != nil {
190+ t .Fatal (err )
191+ }
181192 })
182193
183194 t .Run ("UnMarshalling :" , func (t * testing.T ) {
184195 err := pcObj .UnmarshalJSON (raw )
185- require .Nil (t , err )
186- require .Equal (t , "Earth" , pcObj .Subject .Country [0 ])
187- require .Equal (t , true , pcObj .IsCA )
196+ if err != nil {
197+ t .Fatal (err )
198+ }
199+ if expected := "Earth" ; pcObj .Subject .Country [0 ] != expected {
200+ t .Fatalf ("Expected %s, got %s\n " , expected , pcObj .Subject .Country [0 ])
201+ }
202+ if pcObj .IsCA != true {
203+ t .Fatalf ("Expected %t, got %t\n " , true , pcObj .IsCA )
204+ }
188205 })
189206
190207 }
0 commit comments