Skip to content

Commit

Permalink
expose the identity fields to consumers (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Rutherford authored Dec 10, 2019
1 parent ad97c55 commit f6d8f1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
14 changes: 7 additions & 7 deletions identities/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ import (

// Identity represents an X.509 identity.
type Identity struct {
authorities []*x509.Certificate
certificate *x509.Certificate
key *rsa.PrivateKey
Authorities []*x509.Certificate
Certificate *x509.Certificate
Key *rsa.PrivateKey
}

// NewIdentity returns a new identity.
func NewIdentity(authorities []*x509.Certificate, certificate *x509.Certificate, key *rsa.PrivateKey) *Identity {
return &Identity{
authorities: authorities,
certificate: certificate,
key: key,
Authorities: authorities,
Certificate: certificate,
Key: key,
}
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func (i *Identity) Issue(template Template) (*Identity, error) {
return nil, errors.Wrapf(err, "error signing certificate for [%s]", template.Subject.CommonName)
}

return NewIdentity(append(i.authorities, i.certificate), certificate, key), nil
return NewIdentity(append(i.Authorities, i.Certificate), certificate, key), nil
}

// sign returns a signed certificate for the provided template.
Expand Down
6 changes: 1 addition & 5 deletions identities/identity_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ func (c *IdentityConfig) Build() (*Identity, error) {
return nil, errors.Wrapf(err, "error loading key from [%s]", c.Key)
}

identity := &Identity{
authorities: authorities,
certificate: certificate,
key: key,
}
identity := NewIdentity(authorities, certificate, key)

return identity, nil
}
Expand Down
6 changes: 3 additions & 3 deletions identities/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func TestIdentity(t *testing.T) {
Convey("it returns an instance", func() {

Convey("with the correct authorities", func() {
So(identity.authorities, ShouldResemble, authorities)
So(identity.Authorities, ShouldResemble, authorities)
})

Convey("with the correct certificate", func() {
So(identity.certificate, ShouldEqual, certificate)
So(identity.Certificate, ShouldEqual, certificate)
})

Convey("with the correct key", func() {
So(identity.key, ShouldEqual, key)
So(identity.Key, ShouldEqual, key)
})
})
})
Expand Down

0 comments on commit f6d8f1e

Please sign in to comment.