Fix some more tests, fix cert size check
This commit is contained in:
@ -107,7 +107,7 @@ func (key_certificate KeyCertificate) SigningPublicKeyType() (signing_pubkey_typ
|
||||
if len(key_certificate.SPKType.Bytes()) < 2 {
|
||||
log.WithFields(log.Fields{
|
||||
"at": "(KeyCertificate) SingingPublicKeyType",
|
||||
"data_len": len(*key_certificate.SPKType),
|
||||
"data_len": len(key_certificate.SPKType.Bytes()),
|
||||
"required_len": 2,
|
||||
"reason": "not enough data",
|
||||
}).Error("error retrieving Singning Public Key type")
|
||||
@ -126,7 +126,7 @@ func (key_certificate KeyCertificate) PublicKeyType() (pubkey_type int, err erro
|
||||
if len(key_certificate.PKType.Bytes()) < 2 {
|
||||
log.WithFields(log.Fields{
|
||||
"at": "(KeyCertificate) SingingPublicKeyType",
|
||||
"data_len": len(*key_certificate.PKType),
|
||||
"data_len": len(key_certificate.PKType.Bytes()),
|
||||
"required_len": 2,
|
||||
"reason": "not enough data",
|
||||
}).Error("error retrieving Singning Public Key type")
|
||||
|
@ -138,7 +138,7 @@ func (keys_and_cert KeysAndCert) GetSigningPublicKey() (signing_public_key crypt
|
||||
//
|
||||
func (keys_and_cert KeysAndCert) GetCertificate() (cert CertificateInterface, err error) {
|
||||
data_len := len(keys_and_cert.Cert())
|
||||
if data_len < KEYS_AND_CERT_MIN_SIZE {
|
||||
if data_len < CERT_MIN_SIZE {
|
||||
log.WithFields(log.Fields{
|
||||
"at": "ReadKeysAndCert",
|
||||
"data_len": data_len,
|
||||
@ -147,7 +147,7 @@ func (keys_and_cert KeysAndCert) GetCertificate() (cert CertificateInterface, er
|
||||
}).Error("error parsing keys and cert")
|
||||
err = errors.New("certificate parsing warning: certificate data is shorter than specified by length")
|
||||
}
|
||||
if data_len > KEYS_AND_CERT_MIN_SIZE {
|
||||
if data_len > CERT_MIN_SIZE {
|
||||
log.WithFields(log.Fields{
|
||||
"at": "ReadKeysAndCert",
|
||||
"data_len": data_len,
|
||||
@ -254,7 +254,7 @@ func ReadKeysAndCert(data []byte) (keys_and_cert KeysAndCert, remainder []byte,
|
||||
"reason": "not enough data",
|
||||
}).Error("error parsing keys and cert")
|
||||
err = errors.New("error parsing KeysAndCert: data is smaller than minimum valid size")
|
||||
// return
|
||||
// return
|
||||
}
|
||||
cert, remainder, err := ReadCertificate(data[KEYS_AND_CERT_DATA_SIZE:])
|
||||
if err != nil {
|
||||
|
@ -18,9 +18,9 @@ func TestCertificateWithMissingData(t *testing.T) {
|
||||
assert.Equal("certificate parsing warning: certificate data is shorter than specified by length", err.Error())
|
||||
}
|
||||
cert_bytes := []byte(cert.Cert())
|
||||
// if assert.Equal(len(cert_data), len(cert_bytes)) {
|
||||
assert.Equal(cert_bytes, cert_data, "keys_and_cert.GetCertificate() did not return available data when cert was missing some data")
|
||||
// }
|
||||
// if assert.Equal(len(cert_data), len(cert_bytes)) {
|
||||
assert.Equal(cert_bytes, cert_data, "keys_and_cert.GetCertificate() did not return available data when cert was missing some data")
|
||||
// }
|
||||
}
|
||||
|
||||
func TestCertificateWithValidData(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user