Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#524 Implement adding and requesting root NOC certificates #543

Merged
merged 18 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix linter errors
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois123@gmail.com>
Abdulbois committed Feb 20, 2024

Unverified

The email in this signature doesn’t match the committer email.
commit 224722f30ef8905829ce1c7c5477628ac15e158d
16 changes: 8 additions & 8 deletions x/pki/handler_add_noc_root_cert_test.go
Original file line number Diff line number Diff line change
@@ -186,11 +186,11 @@ func TestHandler_AddNocX509RootCert_AddNew(t *testing.T) {
require.Equal(t, 1, len(approvedCertificatesBySubject.SubjectKeyIds))
require.Equal(t, newNocCertificate.SubjectKeyId, approvedCertificatesBySubject.SubjectKeyIds[0])

approvedCertificatesBySubjectKeyId, err := queryAllApprovedCertificatesBySubjectKeyID(setup, newNocCertificate.SubjectKeyId)
approvedCertificatesBySubjectKeyID, err := queryAllApprovedCertificatesBySubjectKeyID(setup, newNocCertificate.SubjectKeyId)
require.NoError(t, err)
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyId))
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyId[0].Certs))
require.Equal(t, &newNocCertificate, approvedCertificatesBySubjectKeyId[0].Certs[0])
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyID))
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyID[0].Certs))
require.Equal(t, &newNocCertificate, approvedCertificatesBySubjectKeyID[0].Certs[0])

// query noc root certificate by VID
nocRootCertificate, err := querySingleNocRootCertificate(setup, testconstants.Vid)
@@ -248,11 +248,11 @@ func TestHandler_AddNocX509RootCert_Renew(t *testing.T) {
require.Equal(t, newNocCertificate.SubjectKeyId, approvedCertificatesBySubject.SubjectKeyIds[0])

// query noc root certificate by SKID
approvedCertificatesBySubjectKeyId, err := queryAllApprovedCertificatesBySubjectKeyID(setup, newNocCertificate.SubjectKeyId)
approvedCertificatesBySubjectKeyID, err := queryAllApprovedCertificatesBySubjectKeyID(setup, newNocCertificate.SubjectKeyId)
require.NoError(t, err)
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyId))
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyId[0].Certs))
require.Equal(t, &newNocCertificate, approvedCertificatesBySubjectKeyId[0].Certs[0])
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyID))
require.Equal(t, 1, len(approvedCertificatesBySubjectKeyID[0].Certs))
require.Equal(t, &newNocCertificate, approvedCertificatesBySubjectKeyID[0].Certs[0])

// query noc root certificate by VID
nocRootCertificates, err := queryNocRootCertificates(setup, testconstants.Vid)
2 changes: 1 addition & 1 deletion x/pki/keeper/grpc_query_noc_root_certificates_test.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (
"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types"
)

// Prevent strconv unused error
// Prevent strconv unused error.
var _ = strconv.IntSize

func TestNocRootCertificatesQuerySingle(t *testing.T) {
2 changes: 1 addition & 1 deletion x/pki/keeper/noc_root_certificates.go
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ func (k Keeper) RemoveNocRootCertificates(
))
}

// GetAllNocRootCertificates returns all nocRootCertificates
// GetAllNocRootCertificates returns all nocRootCertificates.
func (k Keeper) GetAllNocRootCertificates(ctx sdk.Context) (list []types.NocRootCertificates) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.NocRootCertificatesKeyPrefix))
iterator := sdk.KVStorePrefixIterator(store, []byte{})
2 changes: 1 addition & 1 deletion x/pki/keeper/noc_root_certificates_test.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import (
"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types"
)

// Prevent strconv unused error
// Prevent strconv unused error.
var _ = strconv.IntSize

func createNNocRootCertificates(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.NocRootCertificates {
2 changes: 1 addition & 1 deletion x/pki/module_simulation.go
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ const (
defaultWeightMsgAssignVid int = 100

opWeightMsgAddNocX509RootCert = "op_weight_msg_create_chain"
// TODO: Determine the simulation weight value
// TODO: Determine the simulation weight value.
defaultWeightMsgAddNocX509RootCert int = 100

opWeightMsgRemoveX509Cert = "op_weight_msg_create_chain"
4 changes: 2 additions & 2 deletions x/pki/types/key_noc_root_certificates.go
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@ import "encoding/binary"
var _ binary.ByteOrder

const (
// NocRootCertificatesKeyPrefix is the prefix to retrieve all NocRootCertificates
// NocRootCertificatesKeyPrefix is the prefix to retrieve all NocRootCertificates.
NocRootCertificatesKeyPrefix = "NocRootCertificates/value/"
)

// NocRootCertificatesKey returns the store key to retrieve a NocRootCertificates from the index fields
// NocRootCertificatesKey returns the store key to retrieve a NocRootCertificates from the index fields.
func NocRootCertificatesKey(
vid int32,
) []byte {