@@ -44,20 +44,31 @@ def app
4444 expect ( result [ 'value' ] [ '_output' ] . chomp ) . to match ( /\w + got passed the message: Hello!/ )
4545 end
4646
47- it 'runs an echo task using a private key' do
48- private_key = ENV [ 'BOLT_SSH_KEY' ] || Dir [ "spec/fixtures/keys/id_rsa" ] [ 0 ]
49- private_key_content = File . read ( private_key )
50- target = conn_target ( 'ssh' , options : { 'private-key' => { 'key-data' => private_key_content } } )
51- body = build_task_request ( 'sample::echo' ,
52- target ,
53- message : "Hello!" )
47+ %w[ env rsa ed25519 ] . each do |key_type |
48+ next if key_type == 'env' && ENV [ 'BOLT_SSH_KEY' ] . nil?
49+
50+ context "runs an echo task using an #{ key_type } private key" do
51+ let ( :private_key ) do
52+ key_type == 'env' ? ENV [ 'BOLT_SSH_KEY' ] : Dir [ "spec/fixtures/keys/id_#{ key_type } " ] [ 0 ]
53+ end
54+
55+ it do
56+ private_key_content = File . read ( private_key )
57+ target = conn_target ( 'ssh' , options : { 'private-key' => { 'key-data' => private_key_content } } )
58+ body = build_task_request ( 'sample::echo' ,
59+ target ,
60+ message : "Hello!" )
61+
62+ post path , JSON . generate ( body ) , 'CONTENT_TYPE' => 'text/json'
63+ expect ( last_response ) . to be_ok
64+ expect ( last_response . status ) . to eq ( 200 )
65+ result = JSON . parse ( last_response . body )
66+ expect ( result ) . to include ( 'status' => 'success' )
67+ expect ( result [ 'value' ] [ '_output' ] . chomp ) . to match ( /\w + got passed the message: Hello!/ )
68+ end
69+ end
5470
55- post path , JSON . generate ( body ) , 'CONTENT_TYPE' => 'text/json'
56- expect ( last_response ) . to be_ok
57- expect ( last_response . status ) . to eq ( 200 )
58- result = JSON . parse ( last_response . body )
59- expect ( result ) . to include ( 'status' => 'success' )
60- expect ( result [ 'value' ] [ '_output' ] . chomp ) . to match ( /\w + got passed the message: Hello!/ )
71+ break if key_type == 'env'
6172 end
6273
6374 it 'runs a shareable task' do
0 commit comments