File tree Expand file tree Collapse file tree
chef-server-slice/app/controllers
data/cookbooks/transfer_remote_files/recipes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,15 +45,19 @@ def index
4545
4646 def show
4747 only_provides :json
48- to_send = find_preferred_file (
49- params [ :cookbook_id ] ,
50- :remote_file ,
51- params [ :id ] ,
52- params [ :fqdn ] ,
53- params [ :platform ] ,
54- params [ :version ]
55- )
56- raise NotFound , "Cannot find a suitable file!" unless to_send
48+ begin
49+ to_send = find_preferred_file (
50+ params [ :cookbook_id ] ,
51+ :remote_file ,
52+ params [ :id ] ,
53+ params [ :fqdn ] ,
54+ params [ :platform ] ,
55+ params [ :version ]
56+ )
57+ rescue Chef ::Exceptions ::FileNotFound
58+ raise NotFound , "Cannot find a suitable file!"
59+ end
60+
5761 current_checksum = checksum ( to_send )
5862 Chef ::Log . debug ( "old sum: #{ params [ :checksum ] } , new sum: #{ current_checksum } " )
5963 if current_checksum == params [ :checksum ]
Original file line number Diff line number Diff line change 1+ #
2+ # Cookbook Name:: transfer_remote_files
3+ # Recipe:: default
4+ #
5+ # Copyright 2009, Opscode
6+ #
7+ # Licensed under the Apache License, Version 2.0 (the "License");
8+ # you may not use this file except in compliance with the License.
9+ # You may obtain a copy of the License at
10+ #
11+ # http://www.apache.org/licenses/LICENSE-2.0
12+ #
13+ # Unless required by applicable law or agreed to in writing, software
14+ # distributed under the License is distributed on an "AS IS" BASIS,
15+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+ # See the License for the specific language governing permissions and
17+ # limitations under the License.
18+ #
19+
20+ remote_file "#{ node [ :tmpdir ] } /transfer_a_non-existent_file_from_a_cookbook.txt" do
21+ source "transfer_a_non-existent_file_from_a_cookbook.txt"
22+ end
Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ Feature: Transfer Remote Files
1010 Then the run should exit '0'
1111 And a file named 'transfer_a_file_from_a_cookbook.txt' should contain 'easy like sunday morning'
1212
13+ Scenario : Transfer a non-existent file from a cookbook and should return a 404
14+ Given a validated node
15+ And it includes the recipe 'transfer_remote_files::transfer_a_non-existent_file_from_a_cookbook'
16+ When I run the chef-client
17+ Then the run should exit '1'
18+ And 'stdout' should have '404'
19+
1320 Scenario : Should prefer the file for this specific host
1421 Given a validated node
1522 And it includes the recipe 'transfer_remote_files::should_prefer_the_file_for_this_specific_host'
You can’t perform that action at this time.
0 commit comments