Skip to content

Commit

Permalink
Reworked PKI unit tests to make proper checks of state indexes (#618)
Browse files Browse the repository at this point in the history
Refactoring unit tests for PKI module
  • Loading branch information
Artemkaaas authored Dec 18, 2024
1 parent 52b02ec commit 1b6f68d
Show file tree
Hide file tree
Showing 44 changed files with 7,971 additions and 7,075 deletions.
51 changes: 35 additions & 16 deletions integration_tests/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module/testutil"

"github.com/zigbee-alliance/distributed-compliance-ledger/x/common/types"
)

Expand Down Expand Up @@ -125,7 +124,9 @@ var (
ProgramType = "Some Program Type"
ProgramTypeVersion = "Some Program Type Version"
Transport = "Some Transport"
SoftwareVersionCertificationStatus = uint32(3)
SoftwareVersionCertificationStatus = uint32(
3,
)
ParentChild1 = "parent"
ParentChild2 = "child"
CertificationIDOfSoftwareComponent = "some certification ID of software component"
Expand Down Expand Up @@ -283,7 +284,9 @@ qoAC9NkyqaAFOPZTaK0P/8jvu8m+t9pWmDXPmqdRDgIgI7rI/g8j51RFtlM5CBpH
mUkpxyqvChVI1A0DTVFLJd4=
-----END CERTIFICATE-----`
PAACertWithNumericVidSubject = "MDAxGDAWBgNVBAMMD01hdHRlciBUZXN0IFBBQTEUMBIGCisGAQQBgqJ8AgEMBEZGRjE="
PAACertWithNumericVidSubjectAsText = "CN=Matter Test PAA,1.3.6.1.4.1.37244.2.1=FFF1"
PAACertWithNumericVidSubjectKeyID = "6A:FD:22:77:1F:51:1F:EC:BF:16:41:97:67:10:DC:DC:31:A1:71:7E"
PAACertWithNumericVidSerialNumber = "4ea8e83182d41c1c"
PAACertWithNumericVidVid int32 = 65521
PAACertWithNumericVidDifferentWhitespaces = `
-----BEGIN CERTIFICATE-----
Expand Down Expand Up @@ -348,10 +351,12 @@ cX4wCgYIKoZIzj0EAwIDSAAwRQIhAJbJyM8uAYhgBdj1vHLAe3X9mldpWsSRETET
i+oDPOUDAiAlVJQ75X1T1sR199I+v8/CA2zSm6Y5PsfvrYcUq3GCGQ==
-----END CERTIFICATE-----`

PAICertWithNumericPidVidSubject = "MEYxGDAWBgNVBAMMD01hdHRlciBUZXN0IFBBSTEUMBIGCisGAQQBgqJ8AgEMBEZGRjExFDASBgorBgEEAYKifAICDAQ4MDAw"
PAICertWithNumericPidVidSubjectKeyID = "AF:42:B7:09:4D:EB:D5:15:EC:6E:CF:33:B8:11:15:22:5F:32:52:88"
PAICertWithNumericPidVidVid = 65521
PAICertWithNumericPidVidPid = 32768
PAICertWithNumericPidVidSubject = "MEYxGDAWBgNVBAMMD01hdHRlciBUZXN0IFBBSTEUMBIGCisGAQQBgqJ8AgEMBEZGRjExFDASBgorBgEEAYKifAICDAQ4MDAw"
PAICertWithNumericPidVidSubjectAsText = "CN=Matter Test PAI,1.3.6.1.4.1.37244.2.1=FFF1,1.3.6.1.4.1.37244.2.2=8000"
PAICertWithNumericPidVidSubjectKeyID = "AF:42:B7:09:4D:EB:D5:15:EC:6E:CF:33:B8:11:15:22:5F:32:52:88"
PAICertWithNumericPidVidVid = 65521
PAICertWithNumericPidVidPid = 32768
PAICertWithNumericPidVidSerialNumber = "4498223361705918669"

PAICertWithPidVid = `
-----BEGIN CERTIFICATE-----
Expand Down Expand Up @@ -699,20 +704,28 @@ eujhLsD51w==
RootSubjectKeyIDWithoutColumns = "5A880E6C3653D07FB08971A3F473790930E62BDB"
RootSerialNumber = "442314047376310867378175982234956458728610743315"

RootCertWithSameSubjectAndSKIDSubject = "MIGCMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQ=="
RootCertWithSameSubjectAndSKIDSubjectKeyID = "33:5E:0C:07:44:F8:B5:9C:CD:55:01:9B:6D:71:23:83:6F:D0:D4:BE"
RootCertWithSameSubjectAndSKID1SerialNumber = "1"
RootCertWithSameSubjectAndSKID2SerialNumber = "2"
IntermediateCertWithSameSubjectAndSKIDSubject = "MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQ="
RootCertWithSameSubjectAndSKIDSubject = "MIGCMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQ=="
RootCertWithSameSubjectAndSKIDSubjectAsText = "C=US,ST=New York,L=New York,O=Example Company,OU=Testing Division,CN=www.example.com"
RootCertWithSameSubjectAndSKIDSubjectKeyID = "33:5E:0C:07:44:F8:B5:9C:CD:55:01:9B:6D:71:23:83:6F:D0:D4:BE"
RootCertWithSameSubjectAndSKID1SerialNumber = "1"
RootCertWithSameSubjectAndSKID2SerialNumber = "2"
RootCertWithSameSubjectAndSKID1Issuer = "MIGCMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQ=="
RootCertWithSameSubjectAndSKID2Issuer = "MIGCMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQ=="
IntermediateCertWithSameSubjectAndSKIDSubject = "MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQ="
IntermediateCertWithSameSubjectAndSKIDSubjectAsText = "C=AU,ST=Some-State,O=Internet Widgits Pty Ltd"

IntermediateCertWithSameSubjectIssuer = RootCertWithSameSubjectAndSKIDSubject
IntermediateCertWithSameSubjectAuthorityKeyID = RootCertWithSameSubjectAndSKIDSubjectKeyID
IntermediateCertWithSameSubjectAndSKIDSubjectKeyID = "2E:13:3B:44:52:2C:30:E9:EC:FB:45:FA:5D:E5:04:0A:C1:C6:E6:B9"
IntermediateCertWithSameSubjectAndSKIDIssuer = RootCertWithSameSubjectAndSKIDSubject
IntermediateCertWithSameSubjectAndSKID1SerialNumber = "3"
IntermediateCertWithSameSubjectAndSKID2SerialNumber = "4"
LeafCertWithSameSubjectAndSKIDSubject = "MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQ="
LeafCertWithSameSubjectAndSKIDSubjectAsText = "C=AU,ST=Some-State,O=Internet Widgits Pty Ltd"
LeafCertWithSameSubjectAndSKIDSubjectKeyID = "12:16:55:8E:5E:2A:DF:04:D7:E6:FE:D1:53:69:61:98:EF:17:2F:03"
LeafCertWithSameSubjectAndSKIDSerialNumber = "5"
LeafCertWithSameSubjectIssuer = IntermediateCertWithSameSubjectAndSKIDSubject
LeafCertWithSameSubjectAuthorityKeyID = IntermediateCertWithSameSubjectAndSKIDSubjectKeyID

IntermediateIssuer = "MDQxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApzb21lLXN0YXRlMRAwDgYDVQQKDAdyb290LWNh"
IntermediateAuthorityKeyID = "5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB"
Expand All @@ -722,8 +735,8 @@ eujhLsD51w==
IntermediateSubjectKeyIDWithoutColumns = "4E3B73F4704DC2980DDBC85A5F023BBF8625562B"
IntermediateSerialNumber = "169917617234879872371588777545667947720450185023"

LeafIssuer = "MDwxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApzb21lLXN0YXRlMRgwFgYDVQQKDA9pbnRlcm1lZGlhdGUtY2E="
LeafAuthorityKeyID = "4E:3B:73:F4:70:4D:C2:98:D:DB:C8:5A:5F:02:3B:BF:86:25:56:2B"
LeafIssuer = IntermediateSubject
LeafAuthorityKeyID = IntermediateSubjectKeyID
LeafSubject = "MDExCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApzb21lLXN0YXRlMQ0wCwYDVQQKDARsZWFm"
LeafSubjectAsText = "O=leaf,ST=some-state,C=AU"
LeafSubjectKeyID = "30:F4:65:75:14:20:B2:AF:3D:14:71:17:AC:49:90:93:3E:24:A0:1F"
Expand All @@ -744,9 +757,14 @@ eujhLsD51w==
TestSubjectKeyID = "E2:90:8D:36:9C:3C:A3:C1:13:BB:09:E2:4D:C1:CC:C5:A6:66:91:D4"
TestSerialNumber = "1647312298631"

PAACertWithSameSubjectID1Subject = "MFoxCzAJBgNVBAYTAlVaMQwwCgYDVQQIDANUU0gxETAPBgNVBAcMCFRBU0hLRU5UMQwwCgYDVQQKDANEU1IxCzAJBgNVBAsMAkRDMQ8wDQYDVQQDDAZNQVRURVI="
PAACertWithSameSubjectID2Subject = "MGAxCzAJBgNVBAYTAlVaMQwwCgYDVQQIDANUU0gxETAPBgNVBAcMCFRBU0hLRU5UMQwwCgYDVQQKDANEU1IxEDAOBgNVBAsMB01BVFRFUjIxEDAOBgNVBAMMB01BVFRFUjI="
PAACertWithSameSubjectIDSubjectID = "7F:C5:4C:61:A7:2A:40:02:DA:B3:73:FB:A8:A0:AC:42:2C:44:77:05"
PAACertWithSameSubjectID1Subject = "MFoxCzAJBgNVBAYTAlVaMQwwCgYDVQQIDANUU0gxETAPBgNVBAcMCFRBU0hLRU5UMQwwCgYDVQQKDANEU1IxCzAJBgNVBAsMAkRDMQ8wDQYDVQQDDAZNQVRURVI="
PAACertWithSameSubjectID1SubjectAsText = "C=UZ,ST=TSH,L=TASHKENT,O=DSR,OU=DC,CN=MATTER"
PAACertWithSameSubjectID2Subject = "MGAxCzAJBgNVBAYTAlVaMQwwCgYDVQQIDANUU0gxETAPBgNVBAcMCFRBU0hLRU5UMQwwCgYDVQQKDANEU1IxEDAOBgNVBAsMB01BVFRFUjIxEDAOBgNVBAMMB01BVFRFUjI="
PAACertWithSameSubjectIDSubjectKeyID = "7F:C5:4C:61:A7:2A:40:02:DA:B3:73:FB:A8:A0:AC:42:2C:44:77:05"
PAACertWithSameSubjectIssuer = "MFoxCzAJBgNVBAYTAlVaMQwwCgYDVQQIDANUU0gxETAPBgNVBAcMCFRBU0hLRU5UMQwwCgYDVQQKDANEU1IxCzAJBgNVBAsMAkRDMQ8wDQYDVQQDDAZNQVRURVI="
PAACertWithSameSubjectSerialNumber = "52395954309929518473720319596322683729415766451"
PAACertWithSameSubject2Issuer = "MGAxCzAJBgNVBAYTAlVaMQwwCgYDVQQIDANUU0gxETAPBgNVBAcMCFRBU0hLRU5UMQwwCgYDVQQKDANEU1IxEDAOBgNVBAsMB01BVFRFUjIxEDAOBgNVBAMMB01BVFRFUjI="
PAACertWithSameSubject2SerialNumber = "619677517297003610282920732322368299925590816980"

TestVID1String = "0xA13"
TestPID1String = "0xA11"
Expand All @@ -760,6 +778,7 @@ eujhLsD51w==
TestCertPemVid = 4701

RootCertWithVidSubject = "MIGYMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTEUMBIGCisGAQQBgqJ8AgEMBEZGRjE="
RootCertWithVidSubjectSubjectAsText = "C=US,ST=New York,L=New York,O=Example Company,OU=Testing "
RootCertWithVidSubjectKeyID = "CE:A8:92:66:EA:E0:80:BD:2B:B5:68:E4:0B:07:C4:FA:2C:34:6D:31"
RootCertWithVidSubjectKeyIDWithoutColumns = "CEA89266EAE080BD2BB568E40B07C4FA2C346D31"
RootCertWithVidVid = 65521
Expand Down
38 changes: 21 additions & 17 deletions integration_tests/constants/noc_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ zodhpBXZfzhHDvINejK8wzwWgf7Ds8wk3oENlmAj
NocRootCert1CopySubjectKeyID = "44:EB:4C:62:6B:25:48:CD:A2:B3:1C:87:41:5A:08:E7:2B:B9:83:26"
NocRootCert1CopySerialNumber = "460647353168152946606945669687905527879095841977"
NocRootCert1CopySubjectAsText = "CN=NOC-1,OU=Testing Division,O=Example Company,L=Tashkent,ST=Some State,C=UZ"
NocRootCert1CopyIssuer = "MHoxCzAJBgNVBAYTAlVaMRMwEQYDVQQIDApTb21lIFN0YXRlMREwDwYDVQQHDAhUYXNoa2VudDEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMQ4wDAYDVQQDDAVOT0MtMQ=="

NocRootCert2Subject = "MHoxCzAJBgNVBAYTAlVaMRMwEQYDVQQIDApTb21lIFN0YXRlMREwDwYDVQQHDAhUYXNoa2VudDEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMQ4wDAYDVQQDDAVOT0MtMg=="
NocRootCert2SubjectKeyID = "CF:E6:DD:37:2B:4C:B2:B9:A9:F2:75:30:1C:AA:B1:37:1B:11:7F:1B"
Expand All @@ -157,21 +158,24 @@ zodhpBXZfzhHDvINejK8wzwWgf7Ds8wk3oENlmAj
NocCert1SerialNumber = "631388393741945881054190991612463928825155142122"
NocCert1SubjectAsText = "CN=NOC-child-1,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"

NocCert1CopySubject = "MIGCMQswCQYDVQQGEwJVWjETMBEGA1UECAwKU29tZSBTdGF0ZTETMBEGA1UEBwwKU29tZSBTdGF0ZTEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMRQwEgYDVQQDDAtOT0MtY2hpbGQtMQ=="
NocCert1CopyIssuer = NocRootCert1Subject
NocCert1CopySubjectKeyID = "02:72:6E:BC:BB:EF:D6:BD:8D:9B:42:AE:D4:3C:C0:55:5F:66:3A:B3"
NocCert1CopySerialNumber = "169445068204646961882009388640343665944683778293"
NocCert1CopySubjectAsText = "CN=NOC-child-1,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"

NocCert2Subject = "MIGCMQswCQYDVQQGEwJVWjETMBEGA1UECAwKU29tZSBTdGF0ZTETMBEGA1UEBwwKU29tZSBTdGF0ZTEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMRQwEgYDVQQDDAtOT0MtY2hpbGQtMg=="
NocCert2Issuer = NocRootCert2Subject
NocCert2SubjectKeyID = "87:48:A2:33:12:1F:51:5C:93:E6:90:40:4A:2C:AB:9E:D6:19:E5:AD"
NocCert2SerialNumber = "361372967010167010646904372658654439710639340814"
NocCert2SubjectAsText = "CN=NOC-child-2,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"

NocLeafCert1Subject = "MIGBMQswCQYDVQQGEwJVWjETMBEGA1UECAwKU29tZSBTdGF0ZTETMBEGA1UEBwwKU29tZSBTdGF0ZTEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMRMwEQYDVQQDDApOT0MtbGVhZi0x"
NocLeafCert1Issuer = NocCert1Subject
NocLeafCert1SubjectKeyID = "77:1F:DB:C4:4C:B1:29:7E:3C:EB:3E:D8:2A:38:0B:63:06:07:00:01"
NocLeafCert1SerialNumber = "281347277961838999749763518155363401757954575313"
NocLeafCert1SubjectAsText = "CN=NOC-leaf-1,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"
NocCert1CopySubject = "MIGCMQswCQYDVQQGEwJVWjETMBEGA1UECAwKU29tZSBTdGF0ZTETMBEGA1UEBwwKU29tZSBTdGF0ZTEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMRQwEgYDVQQDDAtOT0MtY2hpbGQtMQ=="
NocCert1CopyIssuer = NocRootCert1Subject
NocCert1CopySubjectKeyID = "02:72:6E:BC:BB:EF:D6:BD:8D:9B:42:AE:D4:3C:C0:55:5F:66:3A:B3"
NocCert1CopySerialNumber = "169445068204646961882009388640343665944683778293"
NocCert1CopyAuthorityKeyID = NocCert1AuthorityKeyID
NocCert1CopySubjectAsText = "CN=NOC-child-1,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"

NocCert2Subject = "MIGCMQswCQYDVQQGEwJVWjETMBEGA1UECAwKU29tZSBTdGF0ZTETMBEGA1UEBwwKU29tZSBTdGF0ZTEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMRQwEgYDVQQDDAtOT0MtY2hpbGQtMg=="
NocCert2Issuer = NocRootCert2Subject
NocCert2AuthorityKeyID = NocRootCert2SubjectKeyID
NocCert2SubjectKeyID = "87:48:A2:33:12:1F:51:5C:93:E6:90:40:4A:2C:AB:9E:D6:19:E5:AD"
NocCert2SerialNumber = "361372967010167010646904372658654439710639340814"
NocCert2SubjectAsText = "CN=NOC-child-2,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"

NocLeafCert1Subject = "MIGBMQswCQYDVQQGEwJVWjETMBEGA1UECAwKU29tZSBTdGF0ZTETMBEGA1UEBwwKU29tZSBTdGF0ZTEYMBYGA1UECgwPRXhhbXBsZSBDb21wYW55MRkwFwYDVQQLDBBUZXN0aW5nIERpdmlzaW9uMRMwEQYDVQQDDApOT0MtbGVhZi0x"
NocLeafCert1Issuer = NocCert1Subject
NocLeafCert1SubjectKeyID = "77:1F:DB:C4:4C:B1:29:7E:3C:EB:3E:D8:2A:38:0B:63:06:07:00:01"
NocLeafCert1SerialNumber = "281347277961838999749763518155363401757954575313"
NocLeafCert1AuthorityKeyID = NocCert1SubjectKeyID
NocLeafCert1SubjectAsText = "CN=NOC-leaf-1,OU=Testing Division,O=Example Company,L=Some State,ST=Some State,C=UZ"
)
5 changes: 0 additions & 5 deletions types/pki/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ func KeyPrefix(p string) []byte {
return []byte(p)
}

const (
ApprovedRootCertificatesKeyPrefix = "ApprovedRootCertificates/value/"
RevokedRootCertificatesKeyPrefix = "RevokedRootCertificates/value/"
)

var (
ApprovedRootCertificatesKey = []byte{0}
RevokedRootCertificatesKey = []byte{0}
Expand Down
2 changes: 1 addition & 1 deletion x/pki/client/cli/query_approved_root_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func CmdShowApprovedRootCertificates() *cobra.Command {
return cli.QueryWithProofList(
clientCtx,
pkitypes.StoreKey,
pkitypes.ApprovedRootCertificatesKeyPrefix,
types.ApprovedRootCertificatesKeyPrefix,
pkitypes.ApprovedRootCertificatesKey,
&res,
)
Expand Down
2 changes: 1 addition & 1 deletion x/pki/client/cli/query_revoked_root_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func CmdShowRevokedRootCertificates() *cobra.Command {
return cli.QueryWithProofList(
clientCtx,
pkitypes.StoreKey,
pkitypes.RevokedRootCertificatesKeyPrefix,
types.RevokedRootCertificatesKeyPrefix,
pkitypes.RevokedRootCertificatesKey,
&res,
)
Expand Down
8 changes: 4 additions & 4 deletions x/pki/keeper/all_certificates_by_subject_key_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types"
)

// SetAllCertificatesBySubjectKeyID set a specific AllCertificatesBySubjectKeyId in the store from its index.
// SetAllCertificatesBySubjectKeyID set a specific AllCertificatesBySubjectKeyID in the store from its index.
func (k Keeper) SetAllCertificatesBySubjectKeyID(ctx sdk.Context, allCertificatesBySubjectKeyID types.AllCertificatesBySubjectKeyId) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.AllCertificatesBySubjectKeyIDKeyPrefix))
b := k.cdc.MustMarshal(&allCertificatesBySubjectKeyID)
Expand Down Expand Up @@ -49,7 +49,7 @@ func (k Keeper) addAllCertificatesBySubjectKeyID(ctx sdk.Context, subjectKeyID s
k.SetAllCertificatesBySubjectKeyID(ctx, AllCertificates)
}

// GetAllCertificatesBySubjectKeyID returns a AllCertificatesBySubjectKeyId from its index.
// GetAllCertificatesBySubjectKeyID returns a AllCertificatesBySubjectKeyID from its index.
func (k Keeper) GetAllCertificatesBySubjectKeyID(
ctx sdk.Context,
subjectKeyID string,
Expand All @@ -69,7 +69,7 @@ func (k Keeper) GetAllCertificatesBySubjectKeyID(
return val, true
}

// RemoveAllCertificatesBySubjectKeyID removes a AllCertificatesBySubjectKeyId from the store.
// RemoveAllCertificatesBySubjectKeyID removes a AllCertificatesBySubjectKeyID from the store.
func (k Keeper) RemoveAllCertificatesBySubjectKeyID(
ctx sdk.Context,
subject string,
Expand Down Expand Up @@ -104,7 +104,7 @@ func (k Keeper) RemoveAllCertificatesBySubjectKeyIDBySerialNumber(ctx sdk.Contex
})
}

// GetAllAllCertificatesBySubjectKeyID returns all AllCertificatesBySubjectKeyId.
// GetAllAllCertificatesBySubjectKeyID returns all AllCertificatesBySubjectKeyID.
func (k Keeper) GetAllAllCertificatesBySubjectKeyID(ctx sdk.Context) (list []types.AllCertificatesBySubjectKeyId) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.AllCertificatesBySubjectKeyIDKeyPrefix))
iterator := sdk.KVStorePrefixIterator(store, []byte{})
Expand Down
6 changes: 3 additions & 3 deletions x/pki/keeper/approved_root_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (

// SetApprovedRootCertificates set approvedRootCertificates in the store.
func (k Keeper) SetApprovedRootCertificates(ctx sdk.Context, approvedRootCertificates types.ApprovedRootCertificates) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(pkitypes.ApprovedRootCertificatesKeyPrefix))
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.ApprovedRootCertificatesKeyPrefix))
b := k.cdc.MustMarshal(&approvedRootCertificates)
store.Set(pkitypes.ApprovedRootCertificatesKey, b)
}

// GetApprovedRootCertificates returns approvedRootCertificates.
func (k Keeper) GetApprovedRootCertificates(ctx sdk.Context) (val types.ApprovedRootCertificates, found bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(pkitypes.ApprovedRootCertificatesKeyPrefix))
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.ApprovedRootCertificatesKeyPrefix))

b := store.Get(pkitypes.ApprovedRootCertificatesKey)
if b == nil {
Expand All @@ -30,7 +30,7 @@ func (k Keeper) GetApprovedRootCertificates(ctx sdk.Context) (val types.Approved

// RemoveApprovedRootCertificates removes approvedRootCertificates from the store.
func (k Keeper) RemoveApprovedRootCertificates(ctx sdk.Context) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(pkitypes.ApprovedRootCertificatesKeyPrefix))
store := prefix.NewStore(ctx.KVStore(k.storeKey), pkitypes.KeyPrefix(types.ApprovedRootCertificatesKeyPrefix))
store.Delete(pkitypes.ApprovedRootCertificatesKey)
}

Expand Down
16 changes: 8 additions & 8 deletions x/pki/keeper/certificate_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func FilterCertificateList(certificates *[]*types.Certificate, predicate Certifi
return result
}

func (k msgServer) AddCertificateToGlobalCertificateIndexes(
func (k Keeper) AddCertificateToGlobalCertificateIndexes(
ctx sdk.Context,
certificate types.Certificate,
) {
Expand All @@ -94,7 +94,7 @@ func (k msgServer) AddCertificateToGlobalCertificateIndexes(
k.AddAllCertificateBySubject(ctx, certificate.Subject, certificate.SubjectKeyId)
}

func (k msgServer) RemoveCertificateFromGlobalCertificateIndexes(
func (k Keeper) RemoveCertificateFromGlobalCertificateIndexes(
ctx sdk.Context,
subject string,
subjectKeyID string,
Expand All @@ -107,7 +107,7 @@ func (k msgServer) RemoveCertificateFromGlobalCertificateIndexes(
k.RemoveAllCertificateBySubject(ctx, subject, subjectKeyID)
}

func (k msgServer) StoreDaCertificate(
func (k Keeper) StoreDaCertificate(
ctx sdk.Context,
certificate types.Certificate,
isRoot bool,
Expand All @@ -133,7 +133,7 @@ func (k msgServer) StoreDaCertificate(
}
}

func (k msgServer) RemoveDaCertificate(
func (k Keeper) RemoveDaCertificate(
ctx sdk.Context,
subject string,
subjectKeyID string,
Expand All @@ -152,7 +152,7 @@ func (k msgServer) RemoveDaCertificate(
}
}

func (k msgServer) RemoveDaCertificateBySerialNumber(
func (k Keeper) RemoveDaCertificateBySerialNumber(
ctx sdk.Context,
subject string,
subjectKeyID string,
Expand All @@ -173,7 +173,7 @@ func (k msgServer) RemoveDaCertificateBySerialNumber(
}
}

func (k msgServer) StoreNocCertificate(
func (k Keeper) StoreNocCertificate(
ctx sdk.Context,
certificate types.Certificate,
isRoot bool) {
Expand Down Expand Up @@ -203,7 +203,7 @@ func (k msgServer) StoreNocCertificate(
}
}

func (k msgServer) RemoveNocCertificate(
func (k Keeper) RemoveNocCertificate(
ctx sdk.Context,
subject string,
subjectKeyID string,
Expand All @@ -229,7 +229,7 @@ func (k msgServer) RemoveNocCertificate(
}
}

func (k msgServer) RemoveNocCertBySerialNumber(
func (k Keeper) RemoveNocCertBySerialNumber(
ctx sdk.Context,
subject string,
subjectKeyID string,
Expand Down
Loading

0 comments on commit 1b6f68d

Please sign in to comment.