Skip to content

Commit

Permalink
Export NewExtraNames
Browse files Browse the repository at this point in the history
  • Loading branch information
areed committed Jan 26, 2024
1 parent c49ba73 commit 3560910
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions x509util/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// attributeTypeNames are the subject attributes managed by Go and this package.
// newExtraNames will populate .Insecure.CR.ExtraNames with the attributes not
// NewExtraNames will populate .Insecure.CR.ExtraNames with the attributes not
// present on this map.
var attributeTypeNames = map[string]string{
"2.5.4.6": "C",
Expand Down Expand Up @@ -54,7 +54,7 @@ func newName(n pkix.Name) Name {
PostalCode: n.PostalCode,
SerialNumber: n.SerialNumber,
CommonName: n.CommonName,
ExtraNames: newExtraNames(n.Names),
ExtraNames: NewExtraNames(n.Names),
}
}

Expand Down Expand Up @@ -154,9 +154,9 @@ type DistinguishedName struct {
Value interface{} `json:"value"`
}

// newExtraNames returns a list of DistinguishedName with the attributes not
// NewExtraNames returns a list of DistinguishedName with the attributes not
// present in attributeTypeNames.
func newExtraNames(atvs []pkix.AttributeTypeAndValue) []DistinguishedName {
func NewExtraNames(atvs []pkix.AttributeTypeAndValue) []DistinguishedName {
var extraNames []DistinguishedName
for _, atv := range atvs {
if _, ok := attributeTypeNames[atv.Type.String()]; !ok {
Expand Down
4 changes: 2 additions & 2 deletions x509util/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func TestIssuer_Set(t *testing.T) {
}
}

func Test_newExtraNames(t *testing.T) {
func Test_NewExtraNames(t *testing.T) {
type args struct {
atvs []pkix.AttributeTypeAndValue
}
Expand All @@ -540,7 +540,7 @@ func Test_newExtraNames(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := newExtraNames(tt.args.atvs); !reflect.DeepEqual(got, tt.want) {
if got := NewExtraNames(tt.args.atvs); !reflect.DeepEqual(got, tt.want) {
t.Errorf("newDistinguisedNames() = %v, want %v", got, tt.want)
}
})
Expand Down

0 comments on commit 3560910

Please sign in to comment.