require 'spec_helper' describe 'App42::Command' do describe "App" do before(:all) do @service = 1 @service_name = 'mysql_demo3' @new_service_name = 'mysql_demo1' @existing_service_name = 'mysql_demo' @service_name_sc = 'mysql_demo@' @old_password = 'wigqled83sh10lvf6ccrdsej78aeq37u' @source_ip = '0.0.0.0/0' @access_time = '2' @iaas = 1 @vm_type = 'Shared' @database = 'demo_development' @os = 1 @vm_config = 1 end context "With valid input data" do it 'Should return service name available' do response = App42::Command::Base.new.service_name_availability @service_name_sc response.should eql @service_name end it 'Should create service' do response = App42::Command::Base.new.create_service @service, @service_name ,@database, @vm_type, @iaas, @vmconfig, @os response.should eql true end it 'should list all services' do response = App42::Command::Service.new.services end it 'Should return correct service information json' do respone = App42::Command::Service.new.info end it 'Should reset service password' do response = App42::Command::Base.new.reset_password @service_name, @old_password response['success'].should eql true end it 'Should bind service with source IP' do response = App42::Command::Base.new.create_service_tunnel @service_name, @source_ip, @access_time end it 'Should Unbind service with source IP' do response = App42::Command::Base.new.delete_service_tunnel @service_name, @source_ip response.should eql true end it 'Should delete service' do response = App42::Command::Base.new.delete_service @service_name response.should eql true end end context "Check service name availability with existing service name" do it 'Should return rest exception: Service with name is not available.' do response = App42::Command::Base.new.service_name_availability @existing_service_name end end context "Create service with existing service name" do it 'Should return rest exception: Service with name is not available.' do response = App42::Command::Base.new.create_service @service, @service_name ,@database, @vm_type, @iaas, @vmconfig, @os response.should eql true end end context "Create service, name contain special charrecter" do it "Service name should not contain any special character and it's length should be less than 30." do response = App42::Command::Base.new.create_service @service, @service_name_sc ,@database, @vm_type, @iaas, @vmconfig, @os end end # Unit testing it "Should return app42PaaS services josn" do response = App42::Command::Service.new.get_services path = "#{APP_ROOT}/app42/spec/data/services.yml" services = YAML.load_file(path) response.should eql services end it "Should return user services josn" do response = App42::Command::Service.new.get_user_services path = "#{APP_ROOT}/app42/spec/data/user_services.yml" service = YAML.load_file(path) response.should eql service end end end