File tree Expand file tree Collapse file tree
chef-server-api/app/controllers
features/api/environments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def create
6060
6161 # PUT /environments/:id
6262 def update
63+ raise Forbidden if params [ :id ] == "_default"
6364 begin
6465 env = Chef ::Environment . cdb_load ( params [ :id ] )
6566 rescue Chef ::Exceptions ::CouchDBNotFound
@@ -75,6 +76,7 @@ def update
7576
7677 # DELETE /environments/:id
7778 def destroy
79+ raise Forbidden if params [ :id ] == "_default"
7880 begin
7981 env = Chef ::Environment . cdb_load ( params [ :id ] )
8082 rescue Chef ::Exceptions ::CouchDBNotFound
Original file line number Diff line number Diff line change @@ -26,3 +26,13 @@ Feature: Delete environments via the REST API
2626 And an 'environment' named 'cucumber' exists
2727 When I 'DELETE' the path '/environments/cucumber'
2828 Then I should get a '403 "Forbidden"' exception
29+
30+ Scenario Outline : Delete the '_default' environment
31+ Given I am <user_type>
32+ When I 'DELETE' the path '/environments/_default'
33+ Then I should get a '403 "Forbidden"' exception
34+
35+ Examples :
36+ | user_type |
37+ | an administrator |
38+ | a non -admin |
Original file line number Diff line number Diff line change @@ -38,3 +38,14 @@ Feature: Update an environment via the REST API
3838 And sending the method 'description' to the 'environment' with 'This will not work'
3939 When I 'PUT' the 'environment' to the path '/environments/cucumber'
4040 Then I should get a '403 "Forbidden"' exception
41+
42+ Scenario Outline : Update the '_default' environment
43+ Given I am <user_type>
44+ And an 'environment' named 'cucumber'
45+ When I 'PUT' the 'environment' to the path '/environments/_default'
46+ Then I should get a '403 "Forbidden"' exception
47+
48+ Examples :
49+ | user_type |
50+ | an administrator |
51+ | a non -admin |
You can’t perform that action at this time.
0 commit comments