Skip to content

Commit

Permalink
pending release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Coretta authored and Jesse Coretta committed Sep 8, 2024
1 parent 18d9a6a commit 70bba16
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 151 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# go-radir

[![Go Report Card](https://goreportcard.com/badge/github.com/oid-directory/go-radir)](https://goreportcard.com/report/github.com/oid-directory/go-radir) [![Go Reference](https://pkg.go.dev/github.com/oid-directory/go-radir?status.svg)](https://pkg.go.dev/github.com/oid-directory/go-radir) ![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)
[![Go Report Card](https://goreportcard.com/badge/github.com/oid-directory/go-radir)](https://goreportcard.com/report/github.com/oid-directory/go-radir) [![Go Reference](https://pkg.go.dev/badge/github.com/oid-directory/go-radir.svg)](https://pkg.go.dev/github.com/oid-directory/go-radir) ![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square) ![Volatility Warning](https://img.shields.io/badge/volatile-darkred?label=%F0%9F%92%A5&labelColor=white&color=orange&cacheSeconds=86400)

Package radir implements subsets of the OID Directory I-D series. See the package documentation by way of the above Go Reference badge. This package, and the documents of its origin, are EXPERIMENTAL and should not be used in production environments.

This package is in its infancy and is quite volatile. Breaking changes are likely.
2 changes: 1 addition & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ Note that this method is immutable, and will not honor any frozen state or
mutex lock.
*/
func (r *Cache) Free() {
*r = Cache{}
*r = Cache{}
}

/*
Expand Down
11 changes: 5 additions & 6 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestCache_codecov(t *testing.T) {
r.X680().SetASN1Notation(`{joint-iso-itu-t(2) asn1(1)}`)
r.X680().SetDotNotation(`2.1`)
r.X680().SetIRI(`/ASN.1`)
r.X660().SetLongArc(`/ASN.1`)
r.X660().SetLongArc(`/ASN.1`)
r.X660().LongArc()

var c *Cache
Expand Down Expand Up @@ -231,15 +231,14 @@ func init() {
courtney.FirstAuthority().SetCN("Courtney Tolana")
courtney.FirstAuthority().SetO("Individual")


limited := NewCache(1,1)
limited := NewCache(1, 1)
limited.Add(threeDee, 0)
limited.Add(threeDee, 1)
limited.Add(twoDee, 0)
limited.Add(twoDee, 1)
limited.Add(jesse,1)
limited.Add(courtney,0)
limited.Add(courtney,1)
limited.Add(jesse, 1)
limited.Add(courtney, 0)
limited.Add(courtney, 1)

myCache.Add(nil, -1)
myCache.Add(threeDee, 0)
Expand Down
2 changes: 1 addition & 1 deletion cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ func (r *DITProfile) NewRegistration(root ...bool) *Registration {
return &Registration{
R_OC: oc,
R_DITProfile: r,
r_root: new(registeredRoot),
r_root: new(registeredRoot),
}
}

Expand Down
2 changes: 1 addition & 1 deletion cfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestDITProfile_codecov(t *testing.T) {
return nil
})
ex := *myDedicatedProfile
ex.R_DN = `adn`
ex.R_DN = `a_dn`
ex.R_OC = []string{`top`, `other`}
X := &ex
X.LDIF()
Expand Down
4 changes: 2 additions & 2 deletions def.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ as follows:
*/
const (
OIDPrefix = `1.3.6.1.4.1.56521.101`
IRIPrefix = `/ISO/Identified-Organization/6/1/4/1/56521/101`
IRIPrefix = `/ISO/Identified-Organization/6/1/4/1/56521/101`
AttributeTypesOIDPrefix = OIDPrefix + `.2.3`
ObjectClassesOIDPrefix = OIDPrefix + `.2.5`
NameFormsOIDPrefix = OIDPrefix + `.2.7`
TwoDimensional = OIDPrefix + `.3.1.2`
ThreeDimensional = OIDPrefix + `.3.1.3`
ASN1Prefix = `{iso identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 56521 oid-directory(101)}`
ASN1Prefix = `{iso identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 56521 oid-directory(101)}`
)

/*
Expand Down
151 changes: 75 additions & 76 deletions gs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func ASN1NotationToMulti(input string) ([]string, error) {

slices[0] = rnanf
if len(slices) == 1 {
return []string{`{`+rnanf+`}`, ``, rid, rnanf, root}, nil
return []string{`{` + rnanf + `}`, ``, rid, rnanf, root}, nil
}

// append root number form to dot
Expand Down Expand Up @@ -140,7 +140,7 @@ func ASN1NotationToMulti(input string) ([]string, error) {
dot = append(dot, n)
}

return []string{`{`+join(slices,` `)+`}`, join(dot, `.`), ident, nanf, nf}, nil
return []string{`{` + join(slices, ` `) + `}`, join(dot, `.`), ident, nanf, nf}, nil
}

func checkASN1Root(slice string) (root, rid, rnanf string, err error) {
Expand Down Expand Up @@ -400,19 +400,19 @@ func DotNotToDN2D(args ...any) (dn any, err error) {
return
}

// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != TwoDimensional {
err = DUAConfigValidityErr
return
}
// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != TwoDimensional {
err = DUAConfigValidityErr
return
}

// store the original OID here, as we'll
// just slap it on our composite DN later.
var O string
Expand Down Expand Up @@ -466,11 +466,11 @@ func DNToDotNot2D(args ...any) (id any, err error) {
return
}

r, ok := args[1].(*X680)
if !ok {
err = NilRegistrationErr
return
}
r, ok := args[1].(*X680)
if !ok {
err = NilRegistrationErr
return
}

var D string
switch tv := args[0].(type) {
Expand All @@ -484,24 +484,24 @@ func DNToDotNot2D(args ...any) (id any, err error) {
return
}

// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != TwoDimensional {
err = DUAConfigValidityErr
return
}

bidx := duaConf.RegistrationSuffixEqual(D)
if bidx == -1 {
err = InvalidDNErr
return
}
// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != TwoDimensional {
err = DUAConfigValidityErr
return
}

bidx := duaConf.RegistrationSuffixEqual(D)
if bidx == -1 {
err = InvalidDNErr
return
}

var N string
if idx := idxRune(D, ','); idx != -1 {
Expand Down Expand Up @@ -558,18 +558,18 @@ func DotNotToDN3D(args ...any) (dn any, err error) {
return
}

// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != ThreeDimensional {
err = DUAConfigValidityErr
return
}
// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != ThreeDimensional {
err = DUAConfigValidityErr
return
}

var D []string // store a portion of the original dotNotation

Expand Down Expand Up @@ -625,34 +625,34 @@ See also [this gist].
[Section 3.1.3 of the RADIT I-D]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-radit#section-3.1.3
*/
func DNToDotNot3D(args ...any) (id any, err error) {
if len(args) < 2 {
err = NilArgumentsErr
return
}

r, ok := args[1].(*X680)
if !ok {
err = NilRegistrationErr
return
}

// Grab our DITProfile instance if defined, else throw
if len(args) < 2 {
err = NilArgumentsErr
return
}

r, ok := args[1].(*X680)
if !ok {
err = NilRegistrationErr
return
}

// Grab our DITProfile instance if defined, else throw
// an error. This is required because we need to know
// the reg. base string value as well as the directory
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != ThreeDimensional {
err = DUAConfigValidityErr
return
}

// Make sure input args[0] type is supported, else bail.
// model in use.
var duaConf *DITProfile = r.DITProfile()
// We want at least one Registration Base
// and our model MUST be 3D. Return error
// value otherwise.
if !duaConf.Valid() || duaConf.Model() != ThreeDimensional {
err = DUAConfigValidityErr
return
}

// Make sure input args[0] type is supported, else bail.
var D string
switch tv := args[0].(type) {
case string:
switch tv := args[0].(type) {
case string:
D = lc(tv)
default:
err = UnsupportedInputTypeErr
Expand Down Expand Up @@ -685,4 +685,3 @@ func DNToDotNot3D(args ...any) (id any, err error) {

return
}

69 changes: 34 additions & 35 deletions gs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,41 @@ func TestASN1NotationToMulti(t *testing.T) {

func TestGS_codecov(t *testing.T) {
ditp2 := &DITProfile{
R_Model: TwoDimensional,
R_RegBase: []string{`ou=Registrations,o=rA`},
}
R_Model: TwoDimensional,
R_RegBase: []string{`ou=Registrations,o=rA`},
}
ditp3 := &DITProfile{
R_Model: ThreeDimensional,
R_RegBase: []string{`ou=Registrations,o=rA`},
}
R_Model: ThreeDimensional,
R_RegBase: []string{`ou=Registrations,o=rA`},
}
twoDc := &Registration{R_DITProfile: ditp2}

_, _ = DNToDotNot3D()
_, _ = DNToDotNot3D(nil,&X667{})
_, _ = DNToDotNot3D(nil,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D([]string{},&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(``,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot3D(`ou=Fake,dc=example,dc=com`,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`dotNotation=Xdc=exampledc=com`,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`n=56521,1,n=4,n=1,6,3,n=1,ou=Registrationso=rA`,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`n=56521,1,n=4,n=1,6,3,n=1,ou=Registrations,o=rA`,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`n=,ou=Registrations,o=rA`,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`,ou=Registrations,o=rA`,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(nil, &X667{})
_, _ = DNToDotNot3D(nil, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D([]string{}, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(``, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot3D(`ou=Fake,dc=example,dc=com`, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`dotNotation=Xdc=exampledc=com`, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`n=56521,1,n=4,n=1,6,3,n=1,ou=Registrationso=rA`, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`n=56521,1,n=4,n=1,6,3,n=1,ou=Registrations,o=rA`, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`n=,ou=Registrations,o=rA`, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot3D(`,ou=Registrations,o=rA`, &X680{r_DITProfile: ditp3})

_, _ = DNToDotNot2D()
_, _ = DNToDotNot2D(nil,&X667{})
_, _ = DNToDotNot2D(nil,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D([]string{},&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(``,&X680{r_DITProfile: ditp3})
_, _ = DNToDotNot2D(`ou=Fake,dc=example,dc=com`,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotNotation=Xdc=exampledc=com`,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotRotation=X,ou=Registrations,o=rA`,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotnotation=X,ou=Registrationso=rA`,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`,ou=Registrations,o=rA`,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotRotation=X,ou=Registrations,o=rA`,&X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(nil, &X667{})
_, _ = DNToDotNot2D(nil, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D([]string{}, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(``, &X680{r_DITProfile: ditp3})
_, _ = DNToDotNot2D(`ou=Fake,dc=example,dc=com`, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotNotation=Xdc=exampledc=com`, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotRotation=X,ou=Registrations,o=rA`, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotnotation=X,ou=Registrationso=rA`, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`,ou=Registrations,o=rA`, &X680{r_DITProfile: ditp2})
_, _ = DNToDotNot2D(`dotRotation=X,ou=Registrations,o=rA`, &X680{r_DITProfile: ditp2})
_, _ = DotNotToDN2D(nil)
_, _ = DotNotToDN2D(nil,&X680{})
_, _ = DotNotToDN2D(nil,&Registration{})
_, _ = DotNotToDN2D(nil, &X680{})
_, _ = DotNotToDN2D(nil, &Registration{})
_, _ = DotNotToDN2D(rune(10), twoDc)
_, _ = DotNotToDN2D(`1.2.X`, twoDc)
_, _ = DotNotToDN3D()
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestGS_codecov(t *testing.T) {
writeString(`cn`, `hi`, valOf(rune(13)))
writeValue(nil, nil, `n`)
var nothing any = `4`
writeValue(&struct{
writeValue(&struct {
n *any `ldap:"n"`
}{
n: &nothing,
Expand All @@ -150,12 +150,12 @@ func TestGS_codecov(t *testing.T) {
func TestTime_codecov(t *testing.T) {
var ts []any = []any{
`20010718155634-0600.019283Z`,
`20010718155634.019283432Z`,
`20010718155634.019283432Z`,
nil,
13,
`200`,
``,
`0600.0192834378297`,
`200`,
``,
`0600.0192834378297`,
}

for _, thyme := range ts {
Expand All @@ -177,7 +177,7 @@ func TestTime_codecov(t *testing.T) {
return
}

if _, err := GeneralizedTimeToTime([]string{`1`,`2`,`3`}); err == nil {
if _, err := GeneralizedTimeToTime([]string{`1`, `2`, `3`}); err == nil {
t.Errorf("%s failed: expected error, got nothing", t.Name())
return
}
Expand All @@ -197,4 +197,3 @@ func TestTime_codecov(t *testing.T) {
return
}
}

Loading

0 comments on commit 70bba16

Please sign in to comment.