refact: to use go-dbw CreateItems, DeleteItems (#4974)
* refact: to use go-dbw CreateItems, DeleteItems Latest version of go-dbw updated the signature of CreateItems(...) and DeleteItems(...) on a happy note this latest version of go-dbw actually does batch inserts and updates for this functions. * all: regenerate protos with new protoc-gen-go version
This commit is contained in:
167 files changed
+2254
-2248
No files matched your search
@@ -550,7 +550,7 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
testPublicId := "test-id"
|
||||
|
||||
testAlgs := []string{string(RS256), string(RS384)}
|
||||
var testSigningAlgs []any
|
||||
var testSigningAlgs []*SigningAlg
|
||||
for _, a := range []Alg{RS256, RS384} {
|
||||
obj, err := NewSigningAlg(ctx, testPublicId, Alg(a))
|
||||
require.NoError(t, err)
|
||||
@@ -558,7 +558,7 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
}
|
||||
|
||||
testAuds := []string{"alice", "eve"}
|
||||
var testAudiences []any
|
||||
var testAudiences []*AudClaim
|
||||
for _, a := range testAuds {
|
||||
obj, err := NewAudClaim(ctx, testPublicId, a)
|
||||
require.NoError(t, err)
|
||||
@@ -569,10 +569,10 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
testCerts := []string{pem}
|
||||
c, err := NewCertificate(ctx, testPublicId, pem)
|
||||
require.NoError(t, err)
|
||||
testCertificates := []any{c}
|
||||
testCertificates := []*Certificate{c}
|
||||
|
||||
testScopes := []string{"profile", "email"}
|
||||
testClaimsScopes := make([]any, 0, len(testScopes))
|
||||
testClaimsScopes := make([]*ClaimsScope, 0, len(testScopes))
|
||||
for _, s := range testScopes {
|
||||
obj, err := NewClaimsScope(ctx, testPublicId, s)
|
||||
require.NoError(t, err)
|
||||
@@ -580,7 +580,7 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
}
|
||||
|
||||
testClaimMaps := []string{"oid=sub", "display_name=name"}
|
||||
testAccountClaimMaps := make([]any, 0, len(testClaimMaps))
|
||||
testAccountClaimMaps := make([]*AccountClaimMap, 0, len(testClaimMaps))
|
||||
acms, err := ParseAccountClaimMaps(ctx, testClaimMaps...)
|
||||
require.NoError(t, err)
|
||||
for _, m := range acms {
|
||||
@@ -592,7 +592,7 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
}
|
||||
|
||||
testPrompts := []string{"consent", "select_account"}
|
||||
testExpectedPrompts := make([]any, 0, len(testPrompts))
|
||||
testExpectedPrompts := make([]*Prompt, 0, len(testPrompts))
|
||||
for _, a := range testPrompts {
|
||||
obj, err := NewPrompt(ctx, testPublicId, PromptParam(a))
|
||||
require.NoError(t, err)
|
||||
@@ -690,11 +690,11 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
} else {
|
||||
want := make([]*AccountClaimMap, 0, len(tt.wantValues.AccountClaimMaps))
|
||||
for _, v := range tt.wantValues.AccountClaimMaps {
|
||||
want = append(want, v.(*AccountClaimMap))
|
||||
want = append(want, v)
|
||||
}
|
||||
got := make([]*AccountClaimMap, 0, len(convertedMaps))
|
||||
for _, v := range convertedMaps {
|
||||
got = append(got, v.(*AccountClaimMap))
|
||||
got = append(got, v)
|
||||
}
|
||||
sort.Slice(want, func(a, b int) bool {
|
||||
return want[a].ToClaim < want[b].ToClaim
|
||||
@@ -730,30 +730,51 @@ func Test_convertValueObjects(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type converted []any
|
||||
type sortableAlgs []*SigningAlg
|
||||
|
||||
func (a converted) Len() int { return len(a) }
|
||||
func (a converted) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a converted) Less(i, j int) bool {
|
||||
switch a[i].(type) {
|
||||
case *SigningAlg:
|
||||
return a[i].(*SigningAlg).GetAlg() < a[j].(*SigningAlg).GetAlg()
|
||||
case *Certificate:
|
||||
return a[i].(*Certificate).GetCert() < a[j].(*Certificate).GetCert()
|
||||
case *AccountClaimMap:
|
||||
return a[i].(*AccountClaimMap).GetToClaim() < a[j].(*AccountClaimMap).GetToClaim()
|
||||
case *AudClaim:
|
||||
return a[i].(*AudClaim).GetAud() < a[j].(*AudClaim).GetAud()
|
||||
case *ClaimsScope:
|
||||
return a[i].(*ClaimsScope).GetScope() < a[j].(*ClaimsScope).GetScope()
|
||||
}
|
||||
return false
|
||||
func (s sortableAlgs) Len() int { return len(s) }
|
||||
func (s sortableAlgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s sortableAlgs) Less(i, j int) bool {
|
||||
return s[i].GetAlg() < s[j].GetAlg()
|
||||
}
|
||||
|
||||
type sortableCerts []*Certificate
|
||||
|
||||
func (s sortableCerts) Len() int { return len(s) }
|
||||
func (s sortableCerts) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s sortableCerts) Less(i, j int) bool {
|
||||
return s[i].GetCert() < s[j].GetCert()
|
||||
}
|
||||
|
||||
type sortableAccountClaimMaps []*AccountClaimMap
|
||||
|
||||
func (s sortableAccountClaimMaps) Len() int { return len(s) }
|
||||
func (s sortableAccountClaimMaps) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s sortableAccountClaimMaps) Less(i, j int) bool {
|
||||
return s[i].GetFromClaim()+s[i].GetToClaim() < s[j].GetFromClaim()+s[j].GetToClaim()
|
||||
}
|
||||
|
||||
type sortableAuds []*AudClaim
|
||||
|
||||
func (s sortableAuds) Len() int { return len(s) }
|
||||
func (s sortableAuds) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s sortableAuds) Less(i, j int) bool {
|
||||
return s[i].GetAud() < s[j].GetAud()
|
||||
}
|
||||
|
||||
type sortableClaimsScopes []*ClaimsScope
|
||||
|
||||
func (s sortableClaimsScopes) Len() int { return len(s) }
|
||||
func (s sortableClaimsScopes) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s sortableClaimsScopes) Less(i, j int) bool {
|
||||
return s[i].GetScope() < s[j].GetScope()
|
||||
}
|
||||
|
||||
func testSortConverted(t *testing.T, c *convertedValues) {
|
||||
sort.Sort(converted(c.Algs))
|
||||
sort.Sort(converted(c.Certs))
|
||||
sort.Sort(converted(c.AccountClaimMaps))
|
||||
sort.Sort(converted(c.Auds))
|
||||
sort.Sort(converted(c.ClaimsScopes))
|
||||
t.Helper()
|
||||
sort.Sort(sortableAlgs(c.Algs))
|
||||
sort.Sort(sortableCerts(c.Certs))
|
||||
sort.Sort(sortableAccountClaimMaps(c.AccountClaimMaps))
|
||||
sort.Sort(sortableAuds(c.Auds))
|
||||
sort.Sort(sortableClaimsScopes(c.ClaimsScopes))
|
||||
}
|
||||
Reference in new issue
Block a user