You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
762 B
Go

package revoking
import (
"math/big"
"math/rand"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
type testRepo struct {
revoked []big.Int
}
func (t *testRepo) StoreRevocation(revoked *CertificateRevoked) error {
t.revoked = append(t.revoked, *revoked.serialNumber)
return nil
}
func TestRevoking(t *testing.T) {
testRepository := testRepo{revoked: make([]big.Int, 0)}
r := NewX509Revoking(&testRepository)
rand.Seed(time.Now().Unix())
serial := big.NewInt(rand.Int63())
revoke, err := r.Revoke(&RevokeCertificate{serialNumber: serial, reason: "for testing"})
assert.NoError(t, err)
assert.Equal(t, "for testing", revoke.reason)
assert.Equal(t, serial, revoke.serialNumber)
assert.Contains(t, testRepository.revoked, *serial)
}