@@ -13,55 +13,53 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
+ import { bundleFromJSON , TransparencyLogEntry } from '@sigstore/bundle' ;
16
17
import { verifyTLogBody } from '../../../tlog/verify/body' ;
17
- import * as sigstore from '../../../types/sigstore' ;
18
18
import bundles from '../../__fixtures__/bundles' ;
19
19
20
20
describe ( 'verifyTLogBody' , ( ) => {
21
21
describe ( 'when a message signature bundle is provided' , ( ) => {
22
22
describe ( 'when everything is valid' , ( ) => {
23
- const bundle = sigstore . bundleFromJSON (
24
- bundles . signature . valid . withSigningCert
25
- ) ;
23
+ const bundle = bundleFromJSON ( bundles . signature . valid . withSigningCert ) ;
26
24
27
25
const tlogEntry = bundle . verificationMaterial
28
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
26
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
29
27
30
28
it ( 'returns true' , ( ) => {
31
29
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( true ) ;
32
30
} ) ;
33
31
} ) ;
34
32
35
33
describe ( 'when the signature does NOT match the value in the tlog entry' , ( ) => {
36
- const bundle = sigstore . bundleFromJSON (
34
+ const bundle = bundleFromJSON (
37
35
bundles . signature . invalid . tlogIncorrectSigInBody
38
36
) ;
39
37
const tlogEntry = bundle . verificationMaterial
40
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
38
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
41
39
42
40
it ( 'returns false' , ( ) => {
43
41
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
44
42
} ) ;
45
43
} ) ;
46
44
47
45
describe ( 'when the digest does NOT match the value in the tlog entry' , ( ) => {
48
- const bundle = sigstore . bundleFromJSON (
46
+ const bundle = bundleFromJSON (
49
47
bundles . signature . invalid . tlogIncorrectDigestInBody
50
48
) ;
51
49
const tlogEntry = bundle . verificationMaterial
52
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
50
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
53
51
54
52
it ( 'returns false' , ( ) => {
55
53
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
56
54
} ) ;
57
55
} ) ;
58
56
59
57
describe ( 'when there is a version mismatch between the tlog entry and the body' , ( ) => {
60
- const bundle = sigstore . bundleFromJSON (
58
+ const bundle = bundleFromJSON (
61
59
bundles . signature . invalid . tlogVersionMismatch
62
60
) ;
63
61
const tlogEntry = bundle . verificationMaterial
64
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
62
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
65
63
66
64
it ( 'returns false' , ( ) => {
67
65
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
@@ -71,69 +69,63 @@ describe('verifyTLogBody', () => {
71
69
72
70
describe ( 'when a DSSE Bundle is provided' , ( ) => {
73
71
describe ( 'when everything is valid' , ( ) => {
74
- const bundle = sigstore . bundleFromJSON (
75
- bundles . dsse . valid . withSigningCert
76
- ) ;
72
+ const bundle = bundleFromJSON ( bundles . dsse . valid . withSigningCert ) ;
77
73
const tlogEntry = bundle . verificationMaterial
78
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
74
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
79
75
80
76
it ( 'returns true' , ( ) => {
81
77
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( true ) ;
82
78
} ) ;
83
79
} ) ;
84
80
85
81
describe ( 'when the payload hash does NOT match the value in the intoto entry' , ( ) => {
86
- const bundle = sigstore . bundleFromJSON ( bundles . dsse . invalid . badSignature ) ;
82
+ const bundle = bundleFromJSON ( bundles . dsse . invalid . badSignature ) ;
87
83
const tlogEntry = bundle . verificationMaterial
88
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
84
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
89
85
90
86
it ( 'returns false' , ( ) => {
91
87
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
92
88
} ) ;
93
89
} ) ;
94
90
95
91
describe ( 'when the signature does NOT match the value in the intoto entry' , ( ) => {
96
- const bundle = sigstore . bundleFromJSON (
92
+ const bundle = bundleFromJSON (
97
93
bundles . dsse . invalid . tlogIncorrectSigInBody
98
94
) ;
99
95
const tlogEntry = bundle . verificationMaterial
100
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
96
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
101
97
102
98
it ( 'returns false' , ( ) => {
103
99
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
104
100
} ) ;
105
101
} ) ;
106
102
107
103
describe ( 'when the tlog entry version is unsupported' , ( ) => {
108
- const bundle = sigstore . bundleFromJSON (
104
+ const bundle = bundleFromJSON (
109
105
bundles . dsse . invalid . tlogUnsupportedVersion
110
106
) ;
111
107
const tlogEntry = bundle . verificationMaterial
112
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
108
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
113
109
114
110
it ( 'returns false' , ( ) => {
115
111
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
116
112
} ) ;
117
113
} ) ;
118
114
119
115
describe ( 'when the signature count does NOT match the intoto entry' , ( ) => {
120
- const bundle = sigstore . bundleFromJSON (
121
- bundles . dsse . invalid . tlogTooManySigsInBody
122
- ) ;
116
+ const bundle = bundleFromJSON ( bundles . dsse . invalid . tlogTooManySigsInBody ) ;
123
117
const tlogEntry = bundle . verificationMaterial
124
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
118
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
125
119
126
120
it ( 'returns false' , ( ) => {
127
121
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
128
122
} ) ;
129
123
} ) ;
130
124
131
125
describe ( 'when there is a version mismatch between the tlog entry and the body' , ( ) => {
132
- const bundle = sigstore . bundleFromJSON (
133
- bundles . dsse . invalid . tlogVersionMismatch
134
- ) ;
126
+ const bundle = bundleFromJSON ( bundles . dsse . invalid . tlogVersionMismatch ) ;
135
127
const tlogEntry = bundle . verificationMaterial
136
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
128
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
137
129
138
130
it ( 'returns false' , ( ) => {
139
131
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( false ) ;
@@ -143,11 +135,9 @@ describe('verifyTLogBody', () => {
143
135
144
136
describe ( 'when a DSSE Bundle w/ dsse tlog entry is provided' , ( ) => {
145
137
describe ( 'when everything is valid' , ( ) => {
146
- const bundle = sigstore . bundleFromJSON (
147
- bundles . dsse . valid . withDSSETLogEntry
148
- ) ;
138
+ const bundle = bundleFromJSON ( bundles . dsse . valid . withDSSETLogEntry ) ;
149
139
const tlogEntry = bundle . verificationMaterial
150
- ?. tlogEntries [ 0 ] as sigstore . VerifiableTransparencyLogEntry ;
140
+ ?. tlogEntries [ 0 ] as TransparencyLogEntry ;
151
141
152
142
it ( 'returns true' , ( ) => {
153
143
expect ( verifyTLogBody ( tlogEntry , bundle . content ) ) . toBe ( true ) ;
0 commit comments