5d0816430f
* rename pkg/linksharing to linksharing * rename pkg/httpserver to linksharing/httpserver * rename pkg/eestream to uplink/eestream * rename pkg/stream to uplink/stream * rename pkg/metainfo/kvmetainfo to uplink/metainfo/kvmetainfo * rename pkg/auth/signing to pkg/signing * rename pkg/storage to uplink/storage * rename pkg/accounting to satellite/accounting * rename pkg/audit to satellite/audit * rename pkg/certdb to satellite/certdb * rename pkg/discovery to satellite/discovery * rename pkg/overlay to satellite/overlay * rename pkg/datarepair to satellite/repair
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package certdb_test
|
|
|
|
import (
|
|
"context"
|
|
"crypto/x509"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/storj/internal/testcontext"
|
|
"storj.io/storj/internal/testidentity"
|
|
"storj.io/storj/satellite"
|
|
"storj.io/storj/satellite/certdb"
|
|
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
|
)
|
|
|
|
func TestCertDB(t *testing.T) {
|
|
satellitedbtest.Run(t, func(t *testing.T, db satellite.DB) {
|
|
ctx := testcontext.New(t)
|
|
defer ctx.Cleanup()
|
|
|
|
testDatabase(ctx, t, db.CertDB())
|
|
})
|
|
}
|
|
|
|
func testDatabase(ctx context.Context, t *testing.T, upldb certdb.DB) {
|
|
//testing variables
|
|
upID, err := testidentity.NewTestIdentity(ctx)
|
|
require.NoError(t, err)
|
|
upIDpubbytes, err := x509.MarshalPKIXPublicKey(upID.Leaf.PublicKey)
|
|
require.NoError(t, err)
|
|
|
|
{ // New entry
|
|
err := upldb.SavePublicKey(ctx, upID.ID, upID.Leaf.PublicKey)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
{ // New entry
|
|
err := upldb.SavePublicKey(ctx, upID.ID, upID.Leaf.PublicKey)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
{ // Get the corresponding Public key for the serialnum
|
|
pubkey, err := upldb.GetPublicKey(ctx, upID.ID)
|
|
assert.NoError(t, err)
|
|
pubbytes, err := x509.MarshalPKIXPublicKey(pubkey)
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, upIDpubbytes, pubbytes)
|
|
}
|
|
}
|