Skip to content

Commit

Permalink
Add schemaVersion into all entities
Browse files Browse the repository at this point in the history
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois123@gmail.com>
  • Loading branch information
Abdulbois committed May 31, 2024
1 parent ba3318e commit 4b7e72f
Show file tree
Hide file tree
Showing 133 changed files with 2,545 additions and 1,711 deletions.
23 changes: 9 additions & 14 deletions integration_tests/cli/pki-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ test_divider
echo "$user_account (Not Trustee) propose Root certificate"
root_path="integration_tests/constants/root_cert"
cert_schema_version_1=1
schema_version_2=2
schema_version_0=0
result=$(echo "$passphrase" | dcld tx pki propose-add-x509-root-cert --certificate="$root_path" --from $user_account --vid $vid --yes)
result=$(get_txn_result "$result")
response_does_not_contain "$result" "\"code\": 0"

echo "$trustee_account (Trustee) propose Root certificate"
result=$(echo "$passphrase" | dcld tx pki propose-add-x509-root-cert --certificate="$root_path" --certificate-schema-version=$cert_schema_version_1 --schemaVersion=$schema_version_2 --from $trustee_account --vid $vid --yes)
result=$(echo "$passphrase" | dcld tx pki propose-add-x509-root-cert --certificate="$root_path" --schemaVersion=$cert_schema_version_1 --from $trustee_account --vid $vid --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand All @@ -206,7 +206,7 @@ echo $result | jq
check_response "$result" "\"subject\": \"$root_cert_subject\""
check_response "$result" "\"subjectKeyId\": \"$root_cert_subject_key_id\""
check_response "$result" "\"certSchemaVersion\": $cert_schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_2"
check_response "$result" "\"schemaVersion\": $schema_version_0"

test_divider

Expand Down Expand Up @@ -390,7 +390,7 @@ test_divider

echo "$vendor_account adds Intermediate certificate"
intermediate_path="integration_tests/constants/intermediate_cert"
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_path" --certificate-schema-version=$cert_schema_version_1 --schemaVersion=$schema_version_2 --from $vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_path" --schemaVersion=$cert_schema_version_1 --from $vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand All @@ -405,7 +405,7 @@ check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_subject_key_id\
check_response "$result" "\"serialNumber\": \"$intermediate_cert_serial_number\""
check_response "$result" "\"subjectAsText\": \"$intermediate_cert_subject_as_text\""
check_response "$result" "\"schemaVersion\": $cert_schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_2"
check_response "$result" "\"schemaVersion\": 0"
check_response "$result" "\"approvals\": \\[\\]"

echo "Request Intermediate certificate by subjectKeyId - There are no approvals for Intermidiate Certificates"
Expand Down Expand Up @@ -680,9 +680,8 @@ result=$(echo "$passphrase" | dcld tx pki revoke-x509-cert --subject="$intermedi
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 4"

revoke_schema_version_3=3
echo "$vendor_account (Not Trustee) revokes only Intermediate certificate. This must not revoke its child - Leaf certificate."
result=$(echo "$passphrase" | dcld tx pki revoke-x509-cert --subject="$intermediate_cert_subject" --subject-key-id="$intermediate_cert_subject_key_id" --schemaVersion=$revoke_schema_version_3 --from=$vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki revoke-x509-cert --subject="$intermediate_cert_subject" --subject-key-id="$intermediate_cert_subject_key_id" --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand Down Expand Up @@ -712,7 +711,6 @@ result=$(dcld query pki all-revoked-x509-certs)
echo $result | jq
check_response "$result" "\"subject\": \"$intermediate_cert_subject\""
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_subject_key_id\""
check_response "$result" "\"schemaVersion\": $revoke_schema_version_3"
response_does_not_contain "$result" "\"subject\": \"$leaf_cert_subject\""
response_does_not_contain "$result" "\"subjectKeyId\": \"$leaf_cert_subject_key_id\""
response_does_not_contain "$result" "\"subject\": \"$root_cert_subject\""
Expand Down Expand Up @@ -822,9 +820,8 @@ test_divider
echo "7. PROPOSE REVOCATION OF ROOT CERT"
test_divider

revoke_schema_version_4=4
echo "$trustee_account (Trustee) proposes to revoke only Root certificate(child certificates should not be revoked)"
result=$(echo "$passphrase" | dcld tx pki propose-revoke-x509-root-cert --subject="$root_cert_subject" --subject-key-id="$root_cert_subject_key_id" --schemaVersion=$revoke_schema_version_4 --from $trustee_account --yes)
result=$(echo "$passphrase" | dcld tx pki propose-revoke-x509-root-cert --subject="$root_cert_subject" --subject-key-id="$root_cert_subject_key_id" --from $trustee_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand All @@ -842,7 +839,6 @@ result=$(dcld query pki all-proposed-x509-root-certs-to-revoke)
echo $result | jq
check_response "$result" "\"subject\": \"$root_cert_subject\""
check_response "$result" "\"subjectKeyId\": \"$root_cert_subject_key_id\""
check_response "$result" "\"schemaVersion\": $revoke_schema_version_4"
response_does_not_contain "$result" "\"subject\": \"$intermediate_cert_subject\""
response_does_not_contain "$result" "\"subjectKeyId\": \"$intermediate_cert_subject_key_id\""
response_does_not_contain "$result" "\"subject\": \"$leaf_cert_subject\""
Expand Down Expand Up @@ -1689,9 +1685,8 @@ response_does_not_contain "$result" "\"subjectAsText\": \"$test_cert_subject_as_

test_divider

reject_schema_version_4=4
echo "$second_trustee_account (Second Trustee) rejects Root certificate"
result=$(echo "$passphrase" | dcld tx pki reject-add-x509-root-cert --subject="$test_cert_subject" --subject-key-id="$test_cert_subject_key_id" --schemaVersion=$reject_schema_version_4 --from $second_trustee_account --yes)
result=$(echo "$passphrase" | dcld tx pki reject-add-x509-root-cert --subject="$test_cert_subject" --subject-key-id="$test_cert_subject_key_id" --from $second_trustee_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand Down Expand Up @@ -1722,7 +1717,7 @@ check_response "$result" "\"serialNumber\": \"$test_cert_serial_number\""
check_response "$result" "\"subjectAsText\": \"$test_cert_subject_as_text\""
check_response "$result" "\"address\": \"$trustee_account_address\""
check_response "$result" "\"address\": \"$second_trustee_account_address\""
check_response "$result" "\"schemaVersion\": $reject_schema_version_4"
check_response "$result" "\"schemaVersion\": $schema_version_0"

test_divider

Expand Down
20 changes: 8 additions & 12 deletions integration_tests/cli/pki-noc-certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ result=$(get_txn_result "$result")
check_response "$result" "\"code\": 414"

cert_schema_version_1=1
schema_version_2=2
echo "Add first NOC root certificate by vendor with VID = $vid"
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-root-cert --certificate="$noc_root_cert_1_path" --certificate-schema-version=$cert_schema_version_1 --schemaVersion=$schema_version_2 --from $vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-root-cert --certificate="$noc_root_cert_1_path" --schemaVersion=$cert_schema_version_1 --from $vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand Down Expand Up @@ -293,14 +292,13 @@ check_response "$result" "\"code\": 439"
test_divider

cert_schema_version_3=3
schema_version_4=4
echo "Add second NOC certificate by vendor with VID = $vid"
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-ica-cert --certificate="$noc_cert_2_path" --certificate-schema-version=$cert_schema_version_3 --from $vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-ica-cert --certificate="$noc_cert_2_path" --schemaVersion=$cert_schema_version_3 --from $vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

echo "Add third NOC certificate by vendor with VID = $vid"
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-ica-cert --certificate="$noc_cert_1_copy_path" --schemaVersion=$schema_version_4 --from $vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-ica-cert --certificate="$noc_cert_1_copy_path" --from $vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand All @@ -317,7 +315,7 @@ check_response "$result" "\"serialNumber\": \"$noc_cert_2_serial_number\""
check_response "$result" "\"vid\": $vid"
check_response "$result" "\"schemaVersion\": $cert_schema_version_0"
check_response "$result" "\"schemaVersion\": $cert_schema_version_3"
check_response "$result" "\"schemaVersion\": $schema_version_4"
check_response "$result" "\"schemaVersion\": $schema_version_0"


echo "Request all approved certificates"
Expand Down Expand Up @@ -366,9 +364,8 @@ result=$(echo "$passphrase" | dcld tx pki revoke-noc-x509-root-cert --subject="$
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 439"

revoke_schema_version_5=5
echo "$vendor_account Vendor revokes only root certificate, it should not revoke intermediate certificates"
result=$(echo "$passphrase" | dcld tx pki revoke-noc-x509-root-cert --subject="$noc_root_cert_1_subject" --subject-key-id="$noc_root_cert_1_subject_key_id" --schemaVersion=$revoke_schema_version_5 --from=$vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki revoke-noc-x509-root-cert --subject="$noc_root_cert_1_subject" --subject-key-id="$noc_root_cert_1_subject_key_id" --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand All @@ -379,7 +376,7 @@ check_response "$result" "\"subject\": \"$noc_root_cert_1_subject"
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_copy_serial_number\""
check_response "$result" "\"schemaVersion\": $revoke_schema_version_5"
check_response "$result" "\"schemaVersion\": $schema_version_0"
response_does_not_contain "$result" "\"subject\": \"$noc_cert_1_subject\""
response_does_not_contain "$result" "\"subject\": \"$noc_leaf_cert_1_subject\""

Expand Down Expand Up @@ -492,9 +489,8 @@ result=$(echo "$passphrase" | dcld tx pki revoke-noc-x509-ica-cert --subject="$n
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 439"

revoke_schema_version_6=6
echo "$vendor_account Vendor revokes only NOC certificates, it should not revoke leaf certificates"
result=$(echo "$passphrase" | dcld tx pki revoke-noc-x509-ica-cert --subject="$noc_cert_1_subject" --subject-key-id="$noc_cert_1_subject_key_id" --schemaVersion=$revoke_schema_version_6 --from=$vendor_account --yes)
result=$(echo "$passphrase" | dcld tx pki revoke-noc-x509-ica-cert --subject="$noc_cert_1_subject" --subject-key-id="$noc_cert_1_subject_key_id" --from=$vendor_account --yes)
result=$(get_txn_result "$result")
check_response "$result" "\"code\": 0"

Expand All @@ -508,7 +504,7 @@ check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_copy_serial_numbe
check_response "$result" "\"subject\": \"$noc_cert_1_subject\""
check_response "$result" "\"subjectKeyId\": \"$noc_cert_1_subject_key_id\""
check_response "$result" "\"serialNumber\": \"$noc_cert_1_serial_number"
check_response "$result" "\"schemaVersion\": $revoke_schema_version_6"
check_response "$result" "\"schemaVersion\": $schema_version_0"
response_does_not_contain "$result" "\"subject\": \"$noc_leaf_cert_1_subject\""
response_does_not_contain "$result" "\"subjectKeyId\": \"$noc_leaf_cert_1_subject_key_id\""
response_does_not_contain "$result" "\"serialNumber\": \"$noc_leaf_cert_1_serial_number"
Expand Down
11 changes: 4 additions & 7 deletions integration_tests/grpc_rest/pki/noc_cert_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ func NocCertDemo(suite *utils.TestSuite) {

// Add first NOC certificate by first vendor
msgAddNocRootCertificate = pkitypes.MsgAddNocX509RootCert{
Signer: vendor1Account.Address,
Cert: testconstants.NocRootCert1,
SchemaVersion: testconstants.SchemaVersion,
Signer: vendor1Account.Address,
Cert: testconstants.NocRootCert1,
}
_, err = suite.BuildAndBroadcastTx([]sdk.Msg{&msgAddNocRootCertificate}, vendor1Name, vendor1Account)
require.NoError(suite.T, err)
Expand All @@ -272,9 +271,8 @@ func NocCertDemo(suite *utils.TestSuite) {

// Add third NOC certificate by second vendor
msgAddNocRootCertificate = pkitypes.MsgAddNocX509RootCert{
Signer: vendor2Account.Address,
Cert: testconstants.NocRootCert3,
SchemaVersion: 1,
Signer: vendor2Account.Address,
Cert: testconstants.NocRootCert3,
}
_, err = suite.BuildAndBroadcastTx([]sdk.Msg{&msgAddNocRootCertificate}, vendor2Name, vendor2Account)
require.NoError(suite.T, err)
Expand Down Expand Up @@ -308,7 +306,6 @@ func NocCertDemo(suite *utils.TestSuite) {
require.Equal(suite.T, 1, len(nocCertificatesByVidAndSkid.Certs))
require.Equal(suite.T, testconstants.NocRootCert3Subject, nocCertificatesByVidAndSkid.Certs[0].Subject)
require.Equal(suite.T, testconstants.NocRootCert3SubjectKeyID, nocCertificatesByVidAndSkid.Certs[0].SubjectKeyId)
require.Equal(suite.T, uint32(1), nocCertificates.SchemaVersion)
require.Equal(suite.T, float32(1), nocCertificatesByVidAndSkid.Tq)

// Request All NOC root certificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message CertifiedModel {
int32 pid = 2;
uint32 softwareVersion = 3;
string certificationType = 4;
bool value = 5;

bool value = 5;
uint32 schemaVersion = 6;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ message ComplianceHistoryItem {
uint32 softwareVersionCertificationStatus = 1;
string date = 2;
string reason = 3;
uint32 cDVersionNumber = 4;
uint32 cDVersionNumber = 4;
uint32 schemaVersion = 5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ import "zigbeealliance/distributedcomplianceledger/compliance/compliance_info.pr
message DeviceSoftwareCompliance {
string cDCertificateId = 1;
repeated ComplianceInfo complianceInfo = 2;
uint32 schemaVersion = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message ProvisionalModel {
int32 pid = 2;
uint32 softwareVersion = 3;
string certificationType = 4;
bool value = 5;

bool value = 5;
uint32 schemaVersion = 6;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message RevokedModel {
int32 pid = 2;
uint32 softwareVersion = 3;
string certificationType = 4;
bool value = 5;

bool value = 5;
uint32 schemaVersion = 6;
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ message Account {
int32 vendorID = 4;
repeated Grant rejects = 5;
repeated common.Uint16Range productIDs = 6;
uint32 schemaVersion = 7;
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ package zigbeealliance.distributedcomplianceledger.dclauth;
option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types";

message AccountStat {
uint64 number = 1;

uint64 number = 1;
uint32 schemaVersion = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ message Grant {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
int64 time = 2; // number of nanoseconds elapsed since January 1, 1970 UTC
string info = 3;
uint32 schemaVersion = 4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ message PendingAccount {
// option (gogoproto.goproto_getters) = false;
// option (gogoproto.goproto_stringer) = false;

Account account = 1 [(gogoproto.embed) = true];
Account account = 1 [(gogoproto.embed) = true];
uint32 pendingAccountSchemaVersion = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ message PendingAccountRevocation {

string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated Grant approvals = 2;

uint32 schemaVersion = 3;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import "zigbeealliance/distributedcomplianceledger/dclauth/account.proto";

message RejectedAccount {
Account account = 1 [(gogoproto.embed) = true];
uint32 rejectedAccountSchemaVersion = 2;
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ message RevokedAccount {
MaliciousValidator = 1;
}
Reason reason = 3;
uint32 revokedAccountSchemaVersion = 4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message ApprovedUpgrade {
cosmos.upgrade.v1beta1.Plan plan = 1 [(gogoproto.nullable) = false];
string creator = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated Grant approvals = 3;
repeated Grant rejects = 4;
repeated Grant rejects = 4;
uint32 schemaVersion = 5;
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ message Grant {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
int64 time = 2; // number of nanoseconds elapsed since January 1, 1970 UTC
string info = 3;
uint32 schemaVersion = 4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message ProposedUpgrade {
cosmos.upgrade.v1beta1.Plan plan = 1 [(gogoproto.nullable) = false];
string creator = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated Grant approvals = 3;
repeated Grant rejects = 4;
repeated Grant rejects = 4;
uint32 schemaVersion = 5;
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ message RejectedUpgrade {
string creator = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated Grant approvals = 3;
repeated Grant rejects = 4;
uint32 schemaVersion = 5;
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/
message ModelVersions {
int32 vid = 1;
int32 pid = 2;
repeated uint32 softwareVersions = 3;
repeated uint32 softwareVersions = 3;
uint32 schemaVersion = 4;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ message Product {
int32 pid = 1;
string name = 2;
string partNumber = 3;
uint32 schemaVersion = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "zigbeealliance/distributedcomplianceledger/model/product.proto";

message VendorProducts {
int32 vid = 1;
repeated Product products = 2;

repeated Product products = 2;
uint32 schemaVersion = 3;
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/

message ApprovedCertificatesBySubject {
string subject = 1;
repeated string subjectKeyIds = 2;

repeated string subjectKeyIds = 2;
uint32 schemaVersion = 3;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ import "zigbeealliance/distributedcomplianceledger/pki/certificate.proto";
message ApprovedCertificatesBySubjectKeyId {
string subjectKeyId = 1;
repeated Certificate certs = 2;
uint32 schemaVersion = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/
import "zigbeealliance/distributedcomplianceledger/pki/certificate_identifier.proto";

message ApprovedRootCertificates {
repeated CertificateIdentifier certs = 1;

repeated CertificateIdentifier certs = 1;
uint32 schemaVersion = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/
message CertificateIdentifier {

string subject = 1;
string subjectKeyId = 2;
string subjectKeyId = 2;
uint32 schemaVersion = 3;
}
Loading

0 comments on commit 4b7e72f

Please sign in to comment.