From 638bf26003db3f959c58bf34dce2d541325e197a Mon Sep 17 00:00:00 2001 From: Anton Chuchkalov Date: Wed, 26 Nov 2014 19:20:58 +0400 Subject: [PATCH] add tests for deploy envs validation --- .../10_create/40_deploy_env.feature.erb | 148 +++++++++++++++++- .../90_delete/20_deploy_env.feature.erb | 2 +- 2 files changed, 146 insertions(+), 4 deletions(-) diff --git a/devops-service/tests/templates/api_v2/10_create/40_deploy_env.feature.erb b/devops-service/tests/templates/api_v2/10_create/40_deploy_env.feature.erb index d513a03..4fafb62 100644 --- a/devops-service/tests/templates/api_v2/10_create/40_deploy_env.feature.erb +++ b/devops-service/tests/templates/api_v2/10_create/40_deploy_env.feature.erb @@ -1,13 +1,14 @@ @project @deploy_env -Feature: Delete deploy env +Feature: Create deploy env - @static <% project_name = @config["static"]["project"]["name"] %> - Scenario: Delete deploy env for project <%= project_name %> + @static + Scenario: Send deploy env with invalid runlist for project <%= project_name %> When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body """ { "deploy_envs": [ + // precreated deploy env { "identifier": "test", "run_list": [], @@ -16,6 +17,147 @@ Feature: Delete deploy env "users": [ "test" ] + }, + // new deploy env + { + "identifier": "test2", + "run_list": [ + "wrongrole[test2_t2]" + ], + "expires": null, + "provider": "static", + "users": [ + "test" + ] + } + ], + "name": "<%= project_name %>" + } + """ + Then response should be '400' + + @static + Scenario: Send deploy env with invalid expiration for project <%= project_name %> + When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body + """ + { + "deploy_envs": [ + // precreated deploy env + { + "identifier": "test", + "run_list": [], + "expires": null, + "provider": "static", + "users": [ + "test" + ] + }, + // new deploy env + { + "identifier": "test2", + "run_list": [], + "expires": "10asd", + "provider": "static", + "users": [ + "test" + ] + } + ], + "name": "<%= project_name %>" + } + """ + Then response should be '400' + + @static + Scenario: Send deploy env with invalid expiration for project <%= project_name %> + When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body + """ + { + "deploy_envs": [ + // precreated deploy env + { + "identifier": "test", + "run_list": [], + "expires": null, + "provider": "static", + "users": [ + "test" + ] + }, + // new deploy env + { + "identifier": "test2", + "run_list": [], + "expires": "10asd", + "provider": "static", + "users": [ + "test" + ] + } + ], + "name": "<%= project_name %>" + } + """ + Then response should be '400' + + @static + Scenario: Send deploy env with invalid user (not present in mongo) for project <%= project_name %> + When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body + """ + { + "deploy_envs": [ + // precreated deploy env + { + "identifier": "test", + "run_list": [], + "expires": null, + "provider": "static", + "users": [ + "test" + ] + }, + // new deploy env + { + "identifier": "test2", + "run_list": [], + "expires": null, + "provider": "static", + "users": [ + "non_existing_user" + ] + } + ], + "name": "<%= project_name %>" + } + """ + Then response should be '400' + + + @static + Scenario: Create deploy env for project <%= project_name %> + When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body + """ + { + "deploy_envs": [ + // precreated deploy env + { + "identifier": "test", + "run_list": [], + "expires": null, + "provider": "static", + "users": [ + "test" + ] + }, + // new deploy env + { + "identifier": "test2", + "run_list": [], + "expires": null, + "provider": "static", + "users": [ + "test" + ] } ], "name": "<%= project_name %>" diff --git a/devops-service/tests/templates/api_v2/90_delete/20_deploy_env.feature.erb b/devops-service/tests/templates/api_v2/90_delete/20_deploy_env.feature.erb index d513a03..2b52d8a 100644 --- a/devops-service/tests/templates/api_v2/90_delete/20_deploy_env.feature.erb +++ b/devops-service/tests/templates/api_v2/90_delete/20_deploy_env.feature.erb @@ -3,7 +3,7 @@ Feature: Delete deploy env @static <% project_name = @config["static"]["project"]["name"] %> - Scenario: Delete deploy env for project <%= project_name %> + Scenario: Delete deploy env of project <%= project_name %> When I send PUT '/v2.0/project/<%= project_name %>' query with JSON body """ {