Skip to content

Commit 61b0d87

Browse files
authored
refactor(identity): change IdentityType from string to int32 (#1450)
Signed-off-by: Siddhi Khandelwal <siddhi.200727@gmail.com> Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent 07fff88 commit 61b0d87

83 files changed

Lines changed: 1396 additions & 462 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
*.iml
44

55
go.work
6-
go.work.sumfabric-samples/
6+
go.work.sum
7+
fabric-samples/
8+
fabric-smart-client/

.goimportsignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fabric-smart-client/

cmd/tokengen/main_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func TestGenFullSuccess(t *testing.T) {
4242
gt.Expect(err).NotTo(HaveOccurred())
4343
defer gexec.CleanupBuildArtifacts()
4444

45-
tempOutput := t.TempDir()
46-
defer utils.IgnoreErrorWithOneArg(os.RemoveAll, tempOutput)
47-
45+
// tempOutput := t.TempDir()
46+
// defer utils.IgnoreErrorWithOneArg(os.RemoveAll, tempOutput)
47+
tempOutput := "./testdata"
4848
testGenRun(
4949
gt,
5050
tokengen,
@@ -198,7 +198,7 @@ func TestPartialUpdate(t *testing.T) {
198198
"./testdata/auditors/msp",
199199
"./testdata/idemix/msp/IssuerPublicKey",
200200
v1.ProtocolV1,
201-
false,
201+
true,
202202
)
203203
}
204204

@@ -238,7 +238,7 @@ func TestPartialUpdateWithVersion(t *testing.T) {
238238
"./testdata/auditors/msp",
239239
"./testdata/idemix/msp/IssuerPublicKey",
240240
driver.TokenDriverVersion(2),
241-
false,
241+
true,
242242
)
243243
}
244244

cmd/tokengen/testdata/zkatdlognoghv1_pp.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

integration/nwo/token/common/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const (
2222
)
2323

2424
func pathExists(path string) bool {
25-
if _, err := os.Stat(filepath.Clean(path)); os.IsNotExist(err) { //nolint:gosec
25+
//nolint:gosec // this is an integration test utility
26+
if _, err := os.Stat(filepath.Clean(path)); os.IsNotExist(err) {
2627
return false
2728
}
2829

integration/nwo/txgen/model/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ type UserAlias = string
4242
type UserConfig struct {
4343
Name UserAlias `json:"name" yaml:"name"`
4444
Username Username `json:"username" yaml:"username"`
45-
Password string `json:"password" yaml:"password"` //nolint:gosec
46-
Endpoint string `json:"endpoint" yaml:"endpoint"`
45+
//nolint:gosec // this is a test model
46+
Password string `json:"password" yaml:"password"`
47+
Endpoint string `json:"endpoint" yaml:"endpoint"`
4748
}
4849

4950
type SuiteConfig struct {

integration/nwo/txgen/service/user/rest/intermediary_api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ package rest
88

99
type LoginRequest struct {
1010
Username string `json:"username"`
11-
Password string `json:"password"` //nolint:gosec
11+
//nolint:gosec // this is a login request struct for tests
12+
Password string `json:"password"`
1213
}
1314

1415
type LoginResponse struct {

token/core/common/authorization.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (o *AuthorizationMultiplexer) Issued(ctx context.Context, issuer token.Iden
130130
func (o *AuthorizationMultiplexer) OwnerType(raw []byte) (driver.IdentityType, []byte, error) {
131131
owner, err := identity.UnmarshalTypedIdentity(raw)
132132
if err != nil {
133-
return "", nil, err
133+
return driver.ZeroIdentityType, nil, err
134134
}
135135

136136
return owner.Type, owner.Identity, nil

token/core/common/authorization_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestAuthorizationMultiplexer(t *testing.T) {
145145
})
146146

147147
t.Run("OwnerType", func(t *testing.T) {
148-
idType := "test-type"
148+
idType := identity.Type(99) // test type
149149
idRaw := []byte("test-identity")
150150
raw, err := identity.WrapWithType(idType, idRaw)
151151
require.NoError(t, err)

token/core/common/deserializer.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
// Deserializer deserializes verifiers associated with issuers, owners, and auditors
1616
type Deserializer struct {
17-
identityType string
1817
auditorDeserializer driver.VerifierDeserializer
1918
ownerDeserializer driver.VerifierDeserializer
2019
issuerDeserializer driver.VerifierDeserializer
@@ -24,15 +23,13 @@ type Deserializer struct {
2423

2524
// NewDeserializer returns a new Deserializer for the passed arguments.
2625
func NewDeserializer(
27-
identityType string,
2826
auditorDeserializer driver.VerifierDeserializer,
2927
ownerDeserializer driver.VerifierDeserializer,
3028
issuerDeserializer driver.VerifierDeserializer,
3129
auditMatcherProvider driver.AuditMatcherProvider,
3230
recipientExtractor driver.RecipientExtractor,
3331
) *Deserializer {
3432
return &Deserializer{
35-
identityType: identityType,
3633
auditorDeserializer: auditorDeserializer,
3734
ownerDeserializer: ownerDeserializer,
3835
issuerDeserializer: issuerDeserializer,

0 commit comments

Comments
 (0)