|
@@ -3,10 +3,12 @@ package main
|
|
import (
|
|
import (
|
|
"bytes"
|
|
"bytes"
|
|
"crypto/rand"
|
|
"crypto/rand"
|
|
|
|
+ "errors"
|
|
"os"
|
|
"os"
|
|
"testing"
|
|
"testing"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
+ "github.com/slackhq/nebula/cert"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/assert"
|
|
"golang.org/x/crypto/ed25519"
|
|
"golang.org/x/crypto/ed25519"
|
|
)
|
|
)
|
|
@@ -76,7 +78,7 @@ func Test_verify(t *testing.T) {
|
|
err = verify([]string{"-ca", caFile.Name(), "-crt", "does_not_exist"}, ob, eb)
|
|
err = verify([]string{"-ca", caFile.Name(), "-crt", "does_not_exist"}, ob, eb)
|
|
assert.Equal(t, "", ob.String())
|
|
assert.Equal(t, "", ob.String())
|
|
assert.Equal(t, "", eb.String())
|
|
assert.Equal(t, "", eb.String())
|
|
- assert.EqualError(t, err, "unable to read crt; open does_not_exist: "+NoSuchFileError)
|
|
|
|
|
|
+ assert.EqualError(t, err, "unable to read crt: open does_not_exist: "+NoSuchFileError)
|
|
|
|
|
|
// invalid crt at path
|
|
// invalid crt at path
|
|
ob.Reset()
|
|
ob.Reset()
|
|
@@ -106,7 +108,7 @@ func Test_verify(t *testing.T) {
|
|
err = verify([]string{"-ca", caFile.Name(), "-crt", certFile.Name()}, ob, eb)
|
|
err = verify([]string{"-ca", caFile.Name(), "-crt", certFile.Name()}, ob, eb)
|
|
assert.Equal(t, "", ob.String())
|
|
assert.Equal(t, "", ob.String())
|
|
assert.Equal(t, "", eb.String())
|
|
assert.Equal(t, "", eb.String())
|
|
- assert.EqualError(t, err, "certificate signature did not match")
|
|
|
|
|
|
+ assert.True(t, errors.Is(err, cert.ErrSignatureMismatch))
|
|
|
|
|
|
// verified cert at path
|
|
// verified cert at path
|
|
crt, _ = NewTestCert(ca, caPriv, "test-cert", time.Now().Add(time.Hour*-1), time.Now().Add(time.Hour), nil, nil, nil)
|
|
crt, _ = NewTestCert(ca, caPriv, "test-cert", time.Now().Add(time.Hour*-1), time.Now().Add(time.Hour), nil, nil, nil)
|