@@ -105,61 +105,76 @@ def test_execute_host
105105 def test_execute_attestation
106106 omit if RUBY_ENGINE == "jruby"
107107
108- @response = "Successfully registered gem: freewill (1.0.0)"
109- @fetcher . data [ "#{ Gem . host } /api/v1/gems" ] = HTTPResponseFactory . create ( body : @response , code : 200 , msg : "OK" )
108+ ENV [ "GITHUB_ACTIONS" ] = "true"
109+ begin
110+ @response = "Successfully registered gem: freewill (1.0.0)"
111+ @fetcher . data [ "#{ Gem . host } /api/v1/gems" ] = HTTPResponseFactory . create ( body : @response , code : 200 , msg : "OK" )
110112
111- File . write ( "#{ @path } .sigstore.json" , "attestation" )
112- @cmd . options [ :args ] = [ @path ]
113- @cmd . options [ :attestations ] = [ "#{ @path } .sigstore.json" ]
113+ File . write ( "#{ @path } .sigstore.json" , "attestation" )
114+ @cmd . options [ :args ] = [ @path ]
115+ @cmd . options [ :attestations ] = [ "#{ @path } .sigstore.json" ]
114116
115- @cmd . execute
117+ @cmd . execute
116118
117- assert_equal Gem ::Net ::HTTP ::Post , @fetcher . last_request . class
118- content_length = @fetcher . last_request [ "Content-Length" ] . to_i
119- assert_equal content_length , @fetcher . last_request . body . length
120- assert_attestation_multipart Gem . read_binary ( "#{ @path } .sigstore.json" )
119+ assert_equal Gem ::Net ::HTTP ::Post , @fetcher . last_request . class
120+ content_length = @fetcher . last_request [ "Content-Length" ] . to_i
121+ assert_equal content_length , @fetcher . last_request . body . length
122+ assert_attestation_multipart Gem . read_binary ( "#{ @path } .sigstore.json" )
123+ ensure
124+ ENV . delete ( "GITHUB_ACTIONS" )
125+ end
121126 end
122127
123128 def test_execute_attestation_auto
124129 omit if RUBY_ENGINE == "jruby"
125130
126- @response = "Successfully registered gem: freewill (1.0.0)"
127- @fetcher . data [ "#{ Gem . host } /api/v1/gems" ] = HTTPResponseFactory . create ( body : @response , code : 200 , msg : "OK" )
131+ ENV [ "GITHUB_ACTIONS" ] = "true"
132+ begin
133+ @response = "Successfully registered gem: freewill (1.0.0)"
134+ @fetcher . data [ "#{ Gem . host } /api/v1/gems" ] = HTTPResponseFactory . create ( body : @response , code : 200 , msg : "OK" )
128135
129- attestation_path = "#{ @path } .sigstore.json"
130- attestation_content = "auto-attestation"
131- File . write ( attestation_path , attestation_content )
132- @cmd . options [ :args ] = [ @path ]
136+ attestation_path = "#{ @path } .sigstore.json"
137+ attestation_content = "auto-attestation"
138+ File . write ( attestation_path , attestation_content )
139+ @cmd . options [ :args ] = [ @path ]
133140
134- @cmd . stub ( :attest! , attestation_path ) do
135- @cmd . execute
136- end
141+ @cmd . stub ( :attest! , attestation_path ) do
142+ @cmd . execute
143+ end
137144
138- assert_equal Gem ::Net ::HTTP ::Post , @fetcher . last_request . class
139- content_length = @fetcher . last_request [ "Content-Length" ] . to_i
140- assert_equal content_length , @fetcher . last_request . body . length
141- assert_attestation_multipart attestation_content
145+ assert_equal Gem ::Net ::HTTP ::Post , @fetcher . last_request . class
146+ content_length = @fetcher . last_request [ "Content-Length" ] . to_i
147+ assert_equal content_length , @fetcher . last_request . body . length
148+ assert_attestation_multipart attestation_content
149+ ensure
150+ ENV . delete ( "GITHUB_ACTIONS" )
151+ end
142152 end
143153
144154 def test_execute_attestation_fallback
145155 omit if RUBY_ENGINE == "jruby"
146156
147- @response = "Successfully registered gem: freewill (1.0.0)"
148- @fetcher . data [ "#{ Gem . host } /api/v1/gems" ] = HTTPResponseFactory . create ( body : @response , code : 200 , msg : "OK" )
157+ ENV [ "GITHUB_ACTIONS" ] = "true"
158+ begin
159+ @response = "Successfully registered gem: freewill (1.0.0)"
160+ @fetcher . data [ "#{ Gem . host } /api/v1/gems" ] = HTTPResponseFactory . create ( body : @response , code : 200 , msg : "OK" )
149161
150- @cmd . options [ :args ] = [ @path ]
162+ @cmd . options [ :args ] = [ @path ]
151163
152- @cmd . stub ( :attest! , proc { raise Gem ::Exception , "boom" } ) do
153- use_ui @ui do
154- @cmd . execute
164+ @cmd . stub ( :attest! , proc { raise Gem ::Exception , "boom" } ) do
165+ use_ui @ui do
166+ @cmd . execute
167+ end
155168 end
156- end
157169
158- assert_match "Failed to push with attestation, retrying without attestation." , @ui . error
159- assert_equal Gem ::Net ::HTTP ::Post , @fetcher . last_request . class
160- assert_equal Gem . read_binary ( @path ) , @fetcher . last_request . body
161- assert_equal "application/octet-stream" ,
162- @fetcher . last_request [ "Content-Type" ]
170+ assert_match "Failed to push with attestation, retrying without attestation." , @ui . error
171+ assert_equal Gem ::Net ::HTTP ::Post , @fetcher . last_request . class
172+ assert_equal Gem . read_binary ( @path ) , @fetcher . last_request . body
173+ assert_equal "application/octet-stream" ,
174+ @fetcher . last_request [ "Content-Type" ]
175+ ensure
176+ ENV . delete ( "GITHUB_ACTIONS" )
177+ end
163178 end
164179
165180 def test_execute_attestation_skipped_on_non_rubygems_host
0 commit comments