diff options
-rw-r--r-- | .travis.yml | 14 | ||||
-rw-r--r-- | Rakefile | 6 | ||||
-rw-r--r-- | pedant.gemfile | 23 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 | ||||
-rw-r--r-- | spec/support/pedant/pedant_config.rb | 121 | ||||
-rw-r--r-- | spec/support/pedant/run_pedant.rb | 63 | ||||
-rw-r--r-- | spec/support/pedant/stickywicket.pem | 27 |
7 files changed, 248 insertions, 7 deletions
diff --git a/.travis.yml b/.travis.yml index b8eb285561..74b7d393ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,11 +11,15 @@ before_install: - gem update --system 2.1.11 - gem --version -rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 - - 2.1.0 +matrix: + include: + - rvm: 1.8.7 + - rvm: 1.9.3 + - rvm: 2.0.0 + - rvm: 2.1.0 + - rvm: 2.1.0 + gemfile: pedant.gemfile + script: bundle exec pedant branches: only: @@ -48,6 +48,10 @@ task :ship => :gem do end end +task :pedant do + require File.expand_path('spec/support/pedant/run_pedant') +end + begin require 'yard' DOC_FILES = [ "README.rdoc", "LICENSE", "spec/tiny_server.rb", "lib/**/*.rb" ] @@ -63,5 +67,3 @@ begin rescue LoadError puts "yard is not available. (sudo) gem install yard to generate yard documentation." end - - diff --git a/pedant.gemfile b/pedant.gemfile new file mode 100644 index 0000000000..cb11eb8aec --- /dev/null +++ b/pedant.gemfile @@ -0,0 +1,23 @@ +source "https://rubygems.org" +gemspec :name => "chef" + +gem 'rest-client', :github => 'opscode/rest-client' +gem 'chef-pedant', :github => 'opscode/chef-pedant', :ref => '4744d7f318b629ff60a0d22cf02296df36936397' +gem 'chef-zero', :github => 'opscode/chef-zero', :ref => 'c0c95d690e1bb7c17c2d141b4937a36c2072d800' +# TODO figure out how to grab this stuff from the main Gemfile +gem "activesupport", "< 4.0.0", :group => :compat_testing, :platform => "ruby" + +group(:docgen) do + gem "yard" +end + +group(:development, :test) do + gem "simplecov" + gem 'rack', "~> 1.5.1" + + gem 'ruby-shadow', :platforms => :ruby unless RUBY_PLATFORM.downcase.match(/(aix|cygwin)/) +end + +# If you want to load debugging tools into the bundle exec sandbox, +# add these additional dependencies into chef/Gemfile.local +eval(IO.read(__FILE__ + '.local'), binding) if File.exists?(__FILE__ + '.local') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2de0cae0ed..09e7642d98 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -82,6 +82,7 @@ require 'spec/support/platform_helpers' # Do not change the gsub. Dir["spec/support/**/*.rb"]. reject { |f| f =~ %r{^spec/support/platforms} }. + reject { |f| f =~ %r{^spec/support/pedant} }. map { |f| f.gsub(%r{.rb$}, '') }. map { |f| f.gsub(%r[spec/], '')}. each { |f| require f } diff --git a/spec/support/pedant/pedant_config.rb b/spec/support/pedant/pedant_config.rb new file mode 100644 index 0000000000..7c9ddd73f1 --- /dev/null +++ b/spec/support/pedant/pedant_config.rb @@ -0,0 +1,121 @@ +# Copyright: Copyright (c) 2012 Opscode, Inc. +# License: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This annotated Pedant configuration file details the various +# configuration settings available to you. It is separate from the +# actual Pedant::Config class because not all settings have sane +# defaults, and not all settings are appropriate in all settings. + +################################################################################ +# You MUST specify the address of the server the API requests will be +# sent to. Only specify protocol, hostname, and port. +chef_server 'http://127.0.0.1:8889' + +# If you are doing development testing, you can specify the address of +# the Solr server. The presence of this parameter will enable tests +# to force commits to Solr, greatly decreasing the amout of time +# needed for testing the search endpoint. This is only an +# optimization for development! If you are testing a "live" Chef +# Server, or otherwise do not have access to the Solr server from your +# testing location, you should not specify a value for this parameter. +# The tests will still run, albeit slower, as they will now need to +# poll for a period to ensure they are querying committed results. +#search_server "http://localhost:8983" + +# Related to the 'search_server' parameter, this specifies the maximum +# amout of time (in seconds) that search endpoint requests should be +# retried before giving up. If not explicitly set, it will default to +# 65 seconds; only set it if you know that your Solr commit interval +# differs significantly from this. +maximum_search_time 0 + +# OSC sends erchef a host header with a port, so this option needs +# # to be enabled for Pedant tests to work correctly +explicit_port_url true + +# We're starting to break tests up into groups based on different +# criteria. The proper API tests (the results of which are viewable +# to OPC customers) should be the only ones run by Pedant embedded in +# OPC installs. There are other specs that help us keep track of API +# cruft that we want to come back and fix later; these shouldn't be +# viewable to customers, but we should be able to run them in +# development and CI environments. If this parameter is missing or +# explicitly `false` only the customer-friendly tests will be run. +# +# This is mainly here for documentation purposes, since the +# command-line `opscode-pedant` utility ultimately determines this +# value. +include_internal false + +# Test users. The five users specified below are required; their +# names (:user, :non_org_user, etc.) are indicative of their role +# within the tests. All users must have a ':name' key. If they have +# a ':create_me' key, Pedant will create these users for you. If you +# are using pre-existing users, you must supply a ':key_file' key, +# which should be the fully-qualified path /on the machine Pedant is +# running on/ to a private key for that user. +key = 'spec/support/pedant/stickywicket.pem' +superuser_name 'admin' +superuser_key key +webui_key key + +# Set the platform_class +platform_class Pedant::OpenSourcePlatform + +requestors({ + :clients => { + # The the admin user, for the purposes of getting things rolling + :admin => { + :name => "pedant_admin_client", + :create_me => true, + :create_knife => true, + :admin => true + }, + :non_admin => { + :name => 'pedant_client', + :create_me => true, + :create_knife => true + }, + :bad => { + :name => 'bad_client', + :bogus => true + } + }, + :users => { + :admin => { + :name => "admin", + :key_file => key, + :create_me => false, + :create_knife => false, + :admin => true + }, + :non_admin => { + :name => "pedant_non_admin_user", + :create_me => true, + :create_knife => true, + :admin => false + }, + # A user for Knife tests. A knife.rb and key files will be set up + # for this user + :knife_user => { + :name => "knifey", + :create_me => true, + :create_knife => true + } + } +}) + +self[:tags] = [:validation, :authentication, :authorization] +verify_error_messages false diff --git a/spec/support/pedant/run_pedant.rb b/spec/support/pedant/run_pedant.rb new file mode 100644 index 0000000000..0c24cf59f8 --- /dev/null +++ b/spec/support/pedant/run_pedant.rb @@ -0,0 +1,63 @@ +#!/usr/bin/env ruby +require 'bundler' +require 'bundler/setup' +require 'chef_zero/server' +require 'rspec/core' +require 'chef/chef_fs/chef_fs_data_store' +require 'chef/chef_fs/config' +require 'tmpdir' +require 'fileutils' +require 'chef/version' + +def start_server(chef_repo_path) + Dir.mkdir(chef_repo_path) if !File.exists?(chef_repo_path) + + # 11.6 and below had a bug where it couldn't create the repo children automatically + if Chef::VERSION.to_f < 11.8 + %w(clients cookbooks data_bags environments nodes roles users).each do |child| + Dir.mkdir("#{chef_repo_path}/#{child}") if !File.exists?("#{chef_repo_path}/#{child}") + end + end + + # Start the new server + Chef::Config.repo_mode = 'everything' + Chef::Config.chef_repo_path = chef_repo_path + Chef::Config.versioned_cookbooks = true + chef_fs = Chef::ChefFS::Config.new.local_fs + data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs) + server = ChefZero::Server.new(:port => 8889, :data_store => data_store)#, :log_level => :debug) + server.start_background + server +end + +tmpdir = Dir.mktmpdir +begin + # Create chef repository + chef_repo_path = "#{tmpdir}/repo" + + # Capture setup data into master_chef_repo_path + server = start_server(chef_repo_path) + + require 'pedant' + require 'pedant/opensource' + + #Pedant::Config.rerun = true + + Pedant.config.suite = 'api' + Pedant.config[:config_file] = 'spec/support/pedant/pedant_config.rb' + Pedant.setup([ + '--skip-knife', + '--skip-validation', + '--skip-authentication', + '--skip-authorization', + '--skip-omnibus' + ]) + + result = RSpec::Core::Runner.run(Pedant.config.rspec_args) + + server.stop if server.running? +ensure + FileUtils.remove_entry_secure(tmpdir) if tmpdir +end + +exit(result) diff --git a/spec/support/pedant/stickywicket.pem b/spec/support/pedant/stickywicket.pem new file mode 100644 index 0000000000..ff09e73903 --- /dev/null +++ b/spec/support/pedant/stickywicket.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA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