forked from TrueCloudLab/certificates
Fix provisioner package move.
This commit is contained in:
parent
1db177b80d
commit
1de8eb4bfa
3 changed files with 10 additions and 12 deletions
|
@ -58,7 +58,6 @@ func New(config *Config) (*Authority, error) {
|
||||||
audiences = append(audiences, fmt.Sprintf("https://%s/sign", name), fmt.Sprintf("https://%s/1.0/sign", name))
|
audiences = append(audiences, fmt.Sprintf("https://%s/sign", name), fmt.Sprintf("https://%s/1.0/sign", name))
|
||||||
}
|
}
|
||||||
audiences = append(audiences, fmt.Sprintf("https://%s:%s/sign", name, port), fmt.Sprintf("https://%s:%s/1.0/sign", name, port))
|
audiences = append(audiences, fmt.Sprintf("https://%s:%s/sign", name, port), fmt.Sprintf("https://%s:%s/1.0/sign", name, port))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var a = &Authority{
|
var a = &Authority{
|
||||||
|
|
|
@ -43,11 +43,11 @@ func (a *Authority) GetProvisioners() ([]*Provisioner, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type uidProvisioner struct {
|
type uidProvisioner struct {
|
||||||
provisioner *provisioner.Provisioner
|
provisioner *Provisioner
|
||||||
uid string
|
uid string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSortedProvisioners(provisioners []*provisioner.Provisioner) (provisionerSlice, error) {
|
func newSortedProvisioners(provisioners []*Provisioner) (provisionerSlice, error) {
|
||||||
if len(provisioners) > math.MaxUint32 {
|
if len(provisioners) > math.MaxUint32 {
|
||||||
return nil, errors.New("too many provisioners")
|
return nil, errors.New("too many provisioners")
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func (p provisionerSlice) Len() int { return len(p) }
|
||||||
func (p provisionerSlice) Less(i, j int) bool { return p[i].uid < p[j].uid }
|
func (p provisionerSlice) Less(i, j int) bool { return p[i].uid < p[j].uid }
|
||||||
func (p provisionerSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
func (p provisionerSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
|
|
||||||
func (p provisionerSlice) Find(cursor string, limit int) ([]*provisioner.Provisioner, string) {
|
func (p provisionerSlice) Find(cursor string, limit int) ([]*Provisioner, string) {
|
||||||
switch {
|
switch {
|
||||||
case limit <= 0:
|
case limit <= 0:
|
||||||
limit = DefaultProvisionersLimit
|
limit = DefaultProvisionersLimit
|
||||||
|
@ -92,7 +92,7 @@ func (p provisionerSlice) Find(cursor string, limit int) ([]*provisioner.Provisi
|
||||||
cursor = fmt.Sprintf("%040s", cursor)
|
cursor = fmt.Sprintf("%040s", cursor)
|
||||||
i := sort.Search(n, func(i int) bool { return p[i].uid >= cursor })
|
i := sort.Search(n, func(i int) bool { return p[i].uid >= cursor })
|
||||||
|
|
||||||
var slice []*provisioner.Provisioner
|
var slice []*Provisioner
|
||||||
for ; i < n && len(slice) < limit; i++ {
|
for ; i < n && len(slice) < limit; i++ {
|
||||||
slice = append(slice, p[i].provisioner)
|
slice = append(slice, p[i].provisioner)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (p provisionerSlice) Find(cursor string, limit int) ([]*provisioner.Provisi
|
||||||
|
|
||||||
// provisionerSum returns the SHA1 of the json representation of the
|
// provisionerSum returns the SHA1 of the json representation of the
|
||||||
// provisioner. From this we will create the unique and sorted id.
|
// provisioner. From this we will create the unique and sorted id.
|
||||||
func provisionerSum(p *provisioner.Provisioner) ([]byte, error) {
|
func provisionerSum(p *Provisioner) ([]byte, error) {
|
||||||
b, err := json.Marshal(p.Key)
|
b, err := json.Marshal(p.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error marshalling provisioner")
|
return nil, errors.Wrap(err, "error marshalling provisioner")
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/smallstep/assert"
|
"github.com/smallstep/assert"
|
||||||
"github.com/smallstep/ca-component/provisioner"
|
|
||||||
"github.com/smallstep/cli/crypto/randutil"
|
"github.com/smallstep/cli/crypto/randutil"
|
||||||
"github.com/smallstep/cli/jose"
|
"github.com/smallstep/cli/jose"
|
||||||
)
|
)
|
||||||
|
@ -127,7 +126,7 @@ func TestGetProvisioners(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateProvisioner(t *testing.T) *provisioner.Provisioner {
|
func generateProvisioner(t *testing.T) *Provisioner {
|
||||||
issuer, err := randutil.Alphanumeric(10)
|
issuer, err := randutil.Alphanumeric(10)
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
// Create a new JWK
|
// Create a new JWK
|
||||||
|
@ -154,7 +153,7 @@ func generateProvisioner(t *testing.T) *provisioner.Provisioner {
|
||||||
public := jwk.Public()
|
public := jwk.Public()
|
||||||
encrypted, err := jwe.CompactSerialize()
|
encrypted, err := jwe.CompactSerialize()
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
return &provisioner.Provisioner{
|
return &Provisioner{
|
||||||
Issuer: issuer,
|
Issuer: issuer,
|
||||||
Type: "JWT",
|
Type: "JWT",
|
||||||
Key: &public,
|
Key: &public,
|
||||||
|
@ -163,7 +162,7 @@ func generateProvisioner(t *testing.T) *provisioner.Provisioner {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_newSortedProvisioners(t *testing.T) {
|
func Test_newSortedProvisioners(t *testing.T) {
|
||||||
provisioners := make([]*provisioner.Provisioner, 20)
|
provisioners := make([]*Provisioner, 20)
|
||||||
for i := range provisioners {
|
for i := range provisioners {
|
||||||
provisioners[i] = generateProvisioner(t)
|
provisioners[i] = generateProvisioner(t)
|
||||||
}
|
}
|
||||||
|
@ -186,7 +185,7 @@ func Test_provisionerSlice_Find(t *testing.T) {
|
||||||
trim := func(s string) string {
|
trim := func(s string) string {
|
||||||
return strings.TrimLeft(s, "0")
|
return strings.TrimLeft(s, "0")
|
||||||
}
|
}
|
||||||
provisioners := make([]*provisioner.Provisioner, 20)
|
provisioners := make([]*Provisioner, 20)
|
||||||
for i := range provisioners {
|
for i := range provisioners {
|
||||||
provisioners[i] = generateProvisioner(t)
|
provisioners[i] = generateProvisioner(t)
|
||||||
}
|
}
|
||||||
|
@ -201,7 +200,7 @@ func Test_provisionerSlice_Find(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
p provisionerSlice
|
p provisionerSlice
|
||||||
args args
|
args args
|
||||||
want []*provisioner.Provisioner
|
want []*Provisioner
|
||||||
want1 string
|
want1 string
|
||||||
}{
|
}{
|
||||||
{"all", ps, args{"", DefaultProvisionersMax}, provisioners[0:20], ""},
|
{"all", ps, args{"", DefaultProvisionersMax}, provisioners[0:20], ""},
|
||||||
|
|
Loading…
Reference in a new issue