@@ -17,7 +17,6 @@ import (
17
17
"time"
18
18
19
19
"github.com/docker/go-plugins-helpers/sdk"
20
- "github.com/stretchr/testify/require"
21
20
)
22
21
23
22
type TestPlugin struct {
@@ -150,21 +149,29 @@ func TestPeerCertificateMarshalJSON(t *testing.T) {
150
149
}
151
150
// generate private key
152
151
privatekey , err := rsa .GenerateKey (rand .Reader , 2048 )
153
- require .NoError (t , err )
152
+ if err != nil {
153
+ t .Fatal (err )
154
+ }
154
155
publickey := & privatekey .PublicKey
155
156
156
157
// create a self-signed certificate. template = parent
157
158
parent := template
158
159
raw , err := x509 .CreateCertificate (rand .Reader , template , parent , publickey , privatekey )
159
- require .NoError (t , err )
160
+ if err != nil {
161
+ t .Fatal (err )
162
+ }
160
163
161
164
cert , err := x509 .ParseCertificate (raw )
162
- require .NoError (t , err )
165
+ if err != nil {
166
+ t .Fatal (err )
167
+ }
163
168
164
169
certs := []* x509.Certificate {cert }
165
170
addr := "www.authz.com/auth"
166
171
req , err := http .NewRequest ("GET" , addr , nil )
167
- require .NoError (t , err )
172
+ if err != nil {
173
+ t .Fatal (err )
174
+ }
168
175
169
176
req .RequestURI = addr
170
177
req .TLS = & tls.ConnectionState {}
@@ -176,15 +183,25 @@ func TestPeerCertificateMarshalJSON(t *testing.T) {
176
183
177
184
t .Run ("Marshalling :" , func (t * testing.T ) {
178
185
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
+ }
181
192
})
182
193
183
194
t .Run ("UnMarshalling :" , func (t * testing.T ) {
184
195
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
+ }
188
205
})
189
206
190
207
}
0 commit comments