(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestEnvelopeAsSignedData(t *testing.T) { |
| 88 | identity := []byte("Foo") |
| 89 | sig := []byte("Bar") |
| 90 | |
| 91 | shdrbytes, err := proto.Marshal(&common.SignatureHeader{Creator: identity}) |
| 92 | if err != nil { |
| 93 | t.Fatalf("%s", err) |
| 94 | } |
| 95 | |
| 96 | env := &common.Envelope{ |
| 97 | Payload: marshalOrPanic(&common.Payload{ |
| 98 | Header: &common.Header{ |
| 99 | SignatureHeader: shdrbytes, |
| 100 | }, |
| 101 | }), |
| 102 | Signature: sig, |
| 103 | } |
| 104 | |
| 105 | signedData, err := protoutil.EnvelopeAsSignedData(env) |
| 106 | if err != nil { |
| 107 | t.Fatalf("Unexpected error converting envelope to SignedData: %s", err) |
| 108 | } |
| 109 | |
| 110 | if len(signedData) != 1 { |
| 111 | t.Fatalf("Expected 1 entry of signed data, but got %d", len(signedData)) |
| 112 | } |
| 113 | |
| 114 | if !bytes.Equal(signedData[0].Identity, identity) { |
| 115 | t.Errorf("Wrong identity bytes") |
| 116 | } |
| 117 | if !bytes.Equal(signedData[0].Data, env.Payload) { |
| 118 | t.Errorf("Wrong data bytes") |
| 119 | } |
| 120 | if !bytes.Equal(signedData[0].Signature, sig) { |
| 121 | t.Errorf("Wrong data bytes") |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestLogMessageForSerializedIdentity(t *testing.T) { |
| 126 | pem, err := readPemFile(filepath.Join("testdata", "peer-expired.pem")) |
nothing calls this directly
no test coverage detected