@@ -44,7 +44,6 @@ import (
4444)
4545
4646var provenanceTests = integration .TestFuncs (
47- testProvenanceAttestation ,
4847 testGitProvenanceAttestationSHA1 ,
4948 testGitProvenanceAttestationSHA256 ,
5049 testMultiPlatformProvenance ,
@@ -180,6 +179,11 @@ RUN echo ok> /foo
180179 _ , isClient := f .(* clientFrontend )
181180 _ , isGateway := f .(* gatewayFrontend )
182181
182+ expCustom := provenancetypes.ProvenanceCustomEnv {
183+ "foo" : "bar" ,
184+ "numbers" : []any {1.0 , 2.0 , 3.0 },
185+ }
186+
183187 if slsaVersion == "v1" {
184188 type stmtT struct {
185189 Predicate provenancetypes.ProvenancePredicateSLSA1 `json:"predicate"`
@@ -193,6 +197,8 @@ RUN echo ok> /foo
193197
194198 require .Equal (t , "" , pred .BuildDefinition .ExternalParameters .ConfigSource .URI )
195199
200+ require .Equal (t , expCustom , pred .BuildDefinition .InternalParameters .ProvenanceCustomEnv )
201+
196202 args := pred .BuildDefinition .ExternalParameters .Request .Args
197203 if isClient {
198204 require .Equal (t , "" , pred .BuildDefinition .ExternalParameters .Request .Frontend )
@@ -294,6 +300,8 @@ RUN echo ok> /foo
294300
295301 require .Equal (t , "" , pred .Invocation .ConfigSource .URI )
296302
303+ require .Equal (t , expCustom , pred .Invocation .Environment .ProvenanceCustomEnv )
304+
297305 args := pred .Invocation .Parameters .Args
298306 if isClient {
299307 require .Equal (t , "" , pred .Invocation .Parameters .Frontend )
@@ -2007,3 +2015,51 @@ COPY --from=base /out /
20072015 require .NoError (t , json .Unmarshal (dt , & pred ))
20082016 }
20092017}
2018+
2019+ type provenanceEnvSimple struct {}
2020+
2021+ func (* provenanceEnvSimple ) UpdateConfigFile (in string ) (string , func () error ) {
2022+ dir , err := os .MkdirTemp ("" , "provenanceenv" )
2023+ if err != nil {
2024+ panic (err )
2025+ }
2026+ dt , err := json .Marshal (map [string ]any {
2027+ "foo" : "bar" ,
2028+ })
2029+ if err != nil {
2030+ panic (err )
2031+ }
2032+ if err := os .WriteFile (filepath .Join (dir , "foo.json" ), dt , 0600 ); err != nil {
2033+ panic (err )
2034+ }
2035+ dt , err = json .Marshal (map [string ]any {
2036+ "numbers" : []int {1 , 2 , 3 },
2037+ })
2038+ if err != nil {
2039+ panic (err )
2040+ }
2041+ if err := os .WriteFile (filepath .Join (dir , "numbers.json" ), dt , 0600 ); err != nil {
2042+ panic (err )
2043+ }
2044+
2045+ // make all paths readable for the rootless user
2046+ if err := os .Chmod (dir , 0755 ); err != nil {
2047+ panic (err )
2048+ }
2049+ if err := os .Chmod (filepath .Join (dir , "foo.json" ), 0644 ); err != nil {
2050+ panic (err )
2051+ }
2052+ if err := os .Chmod (filepath .Join (dir , "numbers.json" ), 0644 ); err != nil {
2053+ panic (err )
2054+ }
2055+
2056+ in = in + fmt .Sprintf ("\n \n provenanceEnvDir = %q\n " , dir )
2057+
2058+ return in , func () error {
2059+ return os .RemoveAll (dir )
2060+ }
2061+ }
2062+
2063+ var (
2064+ provenanceEnvSimpleConfig integration.ConfigUpdater = & provenanceEnvSimple {}
2065+ )
0 commit comments