249244536a
* CSR Service: + implement certificate sign rpc method + implement certificate signer client/server + refactor `AuthorizationDB#Create` + refactor `NewTestIdentity` + add `AuthorizationDB#Claim` + add `Token#Equal` + fix `Authorizations#Marshal` when marshaling identities and certificates + tweak `Authorization#String` format + cert debugging improvements (jsondiff) + receive context arg in `NewTestIdentity` + misc. fixes
36 lines
841 B
Go
36 lines
841 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package testidentity
|
|
|
|
import (
|
|
"context"
|
|
|
|
"storj.io/storj/pkg/provider"
|
|
)
|
|
|
|
// NewTestIdentity is a helper function to generate new node identities with
|
|
// correct difficulty and concurrency
|
|
func NewTestIdentity(ctx context.Context) (*provider.FullIdentity, error) {
|
|
ca, err := provider.NewCA(ctx, provider.NewCAOptions{
|
|
Difficulty: 12,
|
|
Concurrency: 4,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
identity, err := ca.NewIdentity()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return identity, err
|
|
}
|
|
|
|
// NewTestCA returns a ca with a default difficulty and concurrency for use in tests
|
|
func NewTestCA(ctx context.Context) (*provider.FullCertificateAuthority, error) {
|
|
return provider.NewCA(ctx, provider.NewCAOptions{
|
|
Difficulty: 12,
|
|
Concurrency: 4,
|
|
})
|
|
}
|