8
8
9
9
"github.com/google/go-github/v69/github"
10
10
"github.com/migueleliasweb/go-github-mock/src/mock"
11
+ "github.com/stretchr/testify/require"
11
12
12
13
"github.com/slsa-framework/slsa-source-poc/sourcetool/pkg/ghcontrol"
13
14
"github.com/slsa-framework/slsa-source-poc/sourcetool/pkg/slsa"
@@ -40,9 +41,8 @@ func createTestProv(t *testing.T, repoUri, ref, commit string) string {
40
41
}
41
42
42
43
statementBytes , err := json .Marshal (& stmt )
43
- if err != nil {
44
- t .Fatalf ("failure marshalling statement: %v" , err )
45
- }
44
+ require .NoError (t , err , "failure marshalling statement: %v" , err )
45
+
46
46
return string (statementBytes )
47
47
}
48
48
@@ -129,7 +129,7 @@ func assertTagProvPredsEqual(t *testing.T, actual, expected *TagProvenancePred)
129
129
}
130
130
131
131
func TestReadProvSuccess (t * testing.T ) {
132
- testProv := createTestProv (t , "https://github.com/owner/repo" , "main" , "abc123 " )
132
+ testProv := createTestProv (t , "https://github.com/owner/repo" , "main" , "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " )
133
133
ghc := newTestGhConnection ("owner" , "repo" , "branch" ,
134
134
// We just need _some_ rulesets response, we don't care what.
135
135
newTagHygieneRulesetsResponse (123 , github .RulesetTargetTag ,
@@ -138,7 +138,7 @@ func TestReadProvSuccess(t *testing.T) {
138
138
verifier := testsupport .NewMockVerifier ()
139
139
140
140
pa := NewProvenanceAttestor (ghc , verifier )
141
- readStmt , readPred , err := pa .GetProvenance (t .Context (), "abc123 " , "main" )
141
+ readStmt , readPred , err := pa .GetProvenance (t .Context (), "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " , "main" )
142
142
if err != nil {
143
143
t .Fatalf ("error finding prov: %v" , err )
144
144
}
@@ -148,7 +148,7 @@ func TestReadProvSuccess(t *testing.T) {
148
148
}
149
149
150
150
func TestReadProvFailure (t * testing.T ) {
151
- testProv := createTestProv (t , "foo" , "main" , "abc123 " )
151
+ testProv := createTestProv (t , "foo" , "main" , "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " )
152
152
ghc := newTestGhConnection ("owner" , "repo" , "branch" ,
153
153
// We just need _some_ rulesets response, we don't care what.
154
154
newTagHygieneRulesetsResponse (456 , github .RulesetTargetBranch ,
@@ -157,7 +157,7 @@ func TestReadProvFailure(t *testing.T) {
157
157
verifier := testsupport .NewMockVerifier ()
158
158
159
159
pa := NewProvenanceAttestor (ghc , verifier )
160
- _ , readPred , err := pa .GetProvenance (t .Context (), "abc123 " , "main" )
160
+ _ , readPred , err := pa .GetProvenance (t .Context (), "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " , "main" )
161
161
if err != nil {
162
162
t .Fatalf ("error finding prov: %v" , err )
163
163
}
@@ -167,7 +167,7 @@ func TestReadProvFailure(t *testing.T) {
167
167
}
168
168
169
169
func TestCreateTagProvenance (t * testing.T ) {
170
- testVsa := createTestVsa (t , "https://github.com/owner/repo" , "refs/some/ref" , "abc123 " , slsa.SourceVerifiedLevels {"TEST_LEVEL" })
170
+ testVsa := createTestVsa (t , "https://github.com/owner/repo" , "refs/some/ref" , "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " , slsa.SourceVerifiedLevels {"TEST_LEVEL" })
171
171
172
172
ghc := newTestGhConnection ("owner" , "repo" , "branch" ,
173
173
newTagHygieneRulesetsResponse (123 , github .RulesetTargetTag ,
@@ -177,7 +177,7 @@ func TestCreateTagProvenance(t *testing.T) {
177
177
178
178
pa := NewProvenanceAttestor (ghc , verifier )
179
179
180
- stmt , err := pa .CreateTagProvenance (t .Context (), "abc123 " , "refs/tags/v1" , "the-tag-pusher" )
180
+ stmt , err := pa .CreateTagProvenance (t .Context (), "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " , "refs/tags/v1" , "the-tag-pusher" )
181
181
if err != nil {
182
182
t .Fatalf ("error creating tag prov %v" , err )
183
183
}
@@ -190,8 +190,8 @@ func TestCreateTagProvenance(t *testing.T) {
190
190
t .Errorf ("statement pred type %v does not match expected %v" , stmt .GetPredicateType (), TagProvPredicateType )
191
191
}
192
192
193
- if ! DoesSubjectIncludeCommit (stmt , "abc123 " ) {
194
- t .Errorf ("statement subject %v does not match expected %v" , stmt .GetSubject (), "abc123 " )
193
+ if ! DoesSubjectIncludeCommit (stmt , "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " ) {
194
+ t .Errorf ("statement subject %v does not match expected %v" , stmt .GetSubject (), "73f0a864c2c9af12e03dae433a6ff5f5e719d7aa " )
195
195
}
196
196
197
197
tagPred , err := GetTagProvPred (stmt )
0 commit comments