From 168c6412e554833cd760d7e4440a72b04eda3e05 Mon Sep 17 00:00:00 2001 From: Ferran Rodenas Date: Fri, 2 Dec 2011 02:17:33 +0100 Subject: [PATCH] Initial release --- .gitignore | 12 + .rspec | 2 + .travis.yml | 12 + .yardopts | 9 + Gemfile | 3 + LICENSE | 20 + README.md | 122 +++ Rakefile | 28 + cloudfoundry.gemspec | 29 + lib/cloudfoundry.rb | 34 + lib/cloudfoundry/client.rb | 93 ++ lib/cloudfoundry/client/apps.rb | 192 ++++ lib/cloudfoundry/client/info.rb | 29 + lib/cloudfoundry/client/request.rb | 89 ++ lib/cloudfoundry/client/resources.rb | 16 + lib/cloudfoundry/client/response.rb | 68 ++ lib/cloudfoundry/client/services.rb | 122 +++ lib/cloudfoundry/client/users.rb | 121 +++ lib/cloudfoundry/constants.rb | 30 + lib/cloudfoundry/exception.rb | 24 + lib/cloudfoundry/version.rb | 27 + spec/client/apps_spec.rb | 423 +++++++++ spec/client/info_spec.rb | 92 ++ spec/client/resources_spec.rb | 52 ++ spec/client/services_spec.rb | 230 +++++ spec/client/users_spec.rb | 367 ++++++++ spec/client_spec.rb | 110 +++ spec/cloudfoundry_spec.rb | 62 ++ spec/fixtures/admin_logged/client.yml | 85 ++ spec/fixtures/admin_logged/users.yml | 363 ++++++++ .../admin_logged/users_create_action.yml | 36 + .../admin_logged/users_proxy_action.yml | 46 + .../users_proxy_nouser_action.yml | 44 + .../admin_logged/users_unproxy_action.yml | 44 + spec/fixtures/app.js | 16 + spec/fixtures/app.zip | Bin 0 -> 441 bytes spec/fixtures/client.yml | 151 ++++ spec/fixtures/client_invalid.yml | 85 ++ spec/fixtures/cloudfoundry.yml | 124 +++ spec/fixtures/cloudfoundry_vs_client.yml | 159 ++++ spec/fixtures/no_logged/apps.yml | 42 + spec/fixtures/no_logged/client.yml | 42 + spec/fixtures/no_logged/info.yml | 81 ++ spec/fixtures/no_logged/resources.yml | 42 + spec/fixtures/no_logged/services.yml | 42 + spec/fixtures/no_logged/users.yml | 108 +++ .../fixtures/no_logged/users_login_action.yml | 81 ++ .../fixtures/no_logged/users_proxy_action.yml | 42 + .../no_logged/users_unproxy_action.yml | 42 + spec/fixtures/user_logged/apps.yml | 828 ++++++++++++++++++ .../user_logged/apps_create_action.yml | 42 + .../user_logged/apps_directory_action.yml | 48 + .../user_logged/apps_download_action.yml | 55 ++ .../fixtures/user_logged/apps_file_action.yml | 54 ++ .../user_logged/apps_start_action.yml | 81 ++ .../user_logged/apps_stats_action.yml | 44 + .../user_logged/apps_update_info_action.yml | 44 + .../apps_upload_filename_action.yml | 62 ++ .../apps_upload_zipfile_action.yml | 62 ++ spec/fixtures/user_logged/client.yml | 85 ++ spec/fixtures/user_logged/info.yml | 126 +++ spec/fixtures/user_logged/resources.yml | 44 + .../user_logged/resources_check_action.yml | 42 + spec/fixtures/user_logged/services.yml | 354 ++++++++ .../user_logged/services_bind_action.yml | 161 ++++ .../user_logged/services_create_action.yml | 83 ++ .../user_logged/services_unbind_action.yml | 122 +++ .../services_unbind_fail_action.yml | 122 +++ spec/fixtures/user_logged/users.yml | 299 +++++++ .../user_logged/users_proxy_action.yml | 44 + .../user_logged/users_unproxy_action.yml | 44 + spec/spec_helper.rb | 29 + spec/support/cf_connection_helper.rb | 26 + spec/support/vcr.rb | 8 + 74 files changed, 7002 insertions(+) create mode 100755 .gitignore create mode 100755 .rspec create mode 100755 .travis.yml create mode 100644 .yardopts create mode 100755 Gemfile create mode 100755 LICENSE create mode 100755 README.md create mode 100755 Rakefile create mode 100755 cloudfoundry.gemspec create mode 100755 lib/cloudfoundry.rb create mode 100755 lib/cloudfoundry/client.rb create mode 100755 lib/cloudfoundry/client/apps.rb create mode 100755 lib/cloudfoundry/client/info.rb create mode 100755 lib/cloudfoundry/client/request.rb create mode 100644 lib/cloudfoundry/client/resources.rb create mode 100644 lib/cloudfoundry/client/response.rb create mode 100755 lib/cloudfoundry/client/services.rb create mode 100755 lib/cloudfoundry/client/users.rb create mode 100755 lib/cloudfoundry/constants.rb create mode 100755 lib/cloudfoundry/exception.rb create mode 100755 lib/cloudfoundry/version.rb create mode 100755 spec/client/apps_spec.rb create mode 100755 spec/client/info_spec.rb create mode 100644 spec/client/resources_spec.rb create mode 100755 spec/client/services_spec.rb create mode 100755 spec/client/users_spec.rb create mode 100755 spec/client_spec.rb create mode 100755 spec/cloudfoundry_spec.rb create mode 100644 spec/fixtures/admin_logged/client.yml create mode 100644 spec/fixtures/admin_logged/users.yml create mode 100644 spec/fixtures/admin_logged/users_create_action.yml create mode 100644 spec/fixtures/admin_logged/users_proxy_action.yml create mode 100644 spec/fixtures/admin_logged/users_proxy_nouser_action.yml create mode 100644 spec/fixtures/admin_logged/users_unproxy_action.yml create mode 100644 spec/fixtures/app.js create mode 100644 spec/fixtures/app.zip create mode 100644 spec/fixtures/client.yml create mode 100644 spec/fixtures/client_invalid.yml create mode 100644 spec/fixtures/cloudfoundry.yml create mode 100644 spec/fixtures/cloudfoundry_vs_client.yml create mode 100644 spec/fixtures/no_logged/apps.yml create mode 100644 spec/fixtures/no_logged/client.yml create mode 100644 spec/fixtures/no_logged/info.yml create mode 100644 spec/fixtures/no_logged/resources.yml create mode 100644 spec/fixtures/no_logged/services.yml create mode 100644 spec/fixtures/no_logged/users.yml create mode 100644 spec/fixtures/no_logged/users_login_action.yml create mode 100644 spec/fixtures/no_logged/users_proxy_action.yml create mode 100644 spec/fixtures/no_logged/users_unproxy_action.yml create mode 100644 spec/fixtures/user_logged/apps.yml create mode 100644 spec/fixtures/user_logged/apps_create_action.yml create mode 100644 spec/fixtures/user_logged/apps_directory_action.yml create mode 100644 spec/fixtures/user_logged/apps_download_action.yml create mode 100644 spec/fixtures/user_logged/apps_file_action.yml create mode 100644 spec/fixtures/user_logged/apps_start_action.yml create mode 100644 spec/fixtures/user_logged/apps_stats_action.yml create mode 100644 spec/fixtures/user_logged/apps_update_info_action.yml create mode 100644 spec/fixtures/user_logged/apps_upload_filename_action.yml create mode 100644 spec/fixtures/user_logged/apps_upload_zipfile_action.yml create mode 100644 spec/fixtures/user_logged/client.yml create mode 100644 spec/fixtures/user_logged/info.yml create mode 100644 spec/fixtures/user_logged/resources.yml create mode 100644 spec/fixtures/user_logged/resources_check_action.yml create mode 100644 spec/fixtures/user_logged/services.yml create mode 100644 spec/fixtures/user_logged/services_bind_action.yml create mode 100644 spec/fixtures/user_logged/services_create_action.yml create mode 100644 spec/fixtures/user_logged/services_unbind_action.yml create mode 100644 spec/fixtures/user_logged/services_unbind_fail_action.yml create mode 100644 spec/fixtures/user_logged/users.yml create mode 100644 spec/fixtures/user_logged/users_proxy_action.yml create mode 100644 spec/fixtures/user_logged/users_unproxy_action.yml create mode 100755 spec/spec_helper.rb create mode 100755 spec/support/cf_connection_helper.rb create mode 100755 spec/support/vcr.rb diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..0e90832 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.bundle +.DS_Store +.idea +.rbenv-version +.yardoc +Gemfile.lock +doc/* +log/* +pkg/* +vendor/* + + diff --git a/.rspec b/.rspec new file mode 100755 index 0000000..1225cbf --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--colour +--format=nested diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..731f707 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +branches: + only: + - master + +rvm: + - 1.8.7 + - 1.9.2 + - 1.9.3 + - jruby + - rbx + - rbx-19mode + - ree \ No newline at end of file diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..ade0478 --- /dev/null +++ b/.yardopts @@ -0,0 +1,9 @@ +--no-private +--protected +--output-dir doc/yard +--tag authenticated:"Requires a user logged in" +--tag admin:"Requires an admin user logged in" +--markup markdown +- +CHANGELOG.md +LICENSE \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100755 index 0000000..c80ee36 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gemspec diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..12f85c8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2011 Ferran Rodenas + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100755 index 0000000..c8bd473 --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +CloudFoundry Ruby Client Gem +============================ + +This is a Ruby wrapper for the [CloudFoundry](http://cloudfoundry.org/) API, the industry’s first open Platform as a +Service (PaaS) offering. + +Installation +------------ + + gem install cloudfoundry-client + +Continuous Integration +---------------------- + +[![Build Status](https://secure.travis-ci.org/frodenas/cloudfoundry-client.png)](http://travis-ci.org/frodenas/cloudfoundry-client) + +Documentation +------------- + +[http://rdoc.info/gems/cloudfoundry-client](http://rdoc.info/gems/cloudfoundry-client) + +Usage Examples +-------------- + +### Connection and login: + + require "cloudfoundry-client" + cf_client = CloudFoundry::Client.new({:target_url => "https://api.cloudfoundry.com"}) + cf_client.login("user@vcap.me", "password") + +### Retrieve information from target cloud: + + cloud_info = cf_client.cloud_info() + cloud_runtimes_info = cf_client.cloud_runtimes_info() + cloud_services_info = cf_client.cloud_services_info() + +### Actions for applications: + + apps = cf_client.list_apps() + app_info = cf_client.app_info("appname") + app_instances = cf_client.app_instances("appname") + app_stats = cf_client.app_stats("appname") + app_crashes = cf_client.app_crashes("appname") + app_files = cf_client.app_files("appname", "/") + app_files = cf_client.app_files("appname", "/logs/stdout.log") + created = cf_client.create_app("appname", manifest) + updated = cf_client.update_app("appname", manifest) + update_info = cf_client.update_app_info("appname") + deleted = cf_client.delete_app("appname") + uploaded = cf_client.upload_app("appname", zipfile, manifest) + zipfile = cf_client.download_app("appname") + +### Actions for services: + + services = cf_client.list_services() + service_info = cf_client.service_info("redis-12345") + created = cf_client.create_service("redis", "redis-12345") + deleted = cf_client.delete_service("redis-12345") + binded = cf_client.bind_service("redis-12345", "appname") + unbinded = cf_client.unbind_service("redis-12345", "appname") + +### Actions for users (some of them require an admin user): + + users = cf_client.list_users() + user_info = cf_client.user_info("user@vcap.me") + created = cf_client.create_user("user@vcap.me", "password") + updated = cf_client.update_user("user@vcap.me", "new_password") + deleted = cf_client.delete_user("user@vcap.me") + +Contributing +------------ +In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help +improve this project. + +Here are some ways *you* can contribute: + +* by using alpha, beta, and prerelease versions +* by reporting bugs +* by suggesting new features +* by writing or editing documentation +* by writing specifications +* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace) +* by refactoring code +* by closing [issues](http://github.com/frodenas/cloudfoundry-client/issues) +* by reviewing patches + + +Submitting an Issue +------------------- +We use the [GitHub issue tracker](http://github.com/frodenas/cloudfoundry-client/issues) to track bugs and features. +Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate +support for an existing issuse by voting it up. When submitting a bug report, please include a +[Gist](http://gist.github.com/) that includes a stack trace and any details that may be necessary to reproduce the bug, +including your gem version, Ruby version, and operating system. Ideally, a bug report should include a pull request with + failing specs. + + +Submitting a Pull Request +------------------------- +1. Fork the project. +2. Create a topic branch. +3. Implement your feature or bug fix. +4. Add documentation for your feature or bug fix. +5. Run rake doc:yard. If your changes are not 100% documented, go back to step 4. +6. Add specs for your feature or bug fix. +7. Run rake spec. If your changes are not 100% covered, go back to step 6. +8. Commit and push your changes. +9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create +your own version for some reason, please do so in a separate commit.) + + +Authors +------- + +By [Ferran Rodenas](http://www.rodenas.org/) +Based on the [VMC - VMware Cloud CLI](https://github.com/cloudfoundry/vmc) + +Copyright +--------- + +See [LICENSE](https://github.com/frodenas/cloudfoundry-client/blob/master/LICENSE) for details. +Copyright (c) 2011 [Ferran Rodenas](http://www.rodenas.org/). \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100755 index 0000000..4239d04 --- /dev/null +++ b/Rakefile @@ -0,0 +1,28 @@ +require 'bundler' +Bundler::GemHelper.install_tasks + +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) + +task :test => :spec +task :default => :spec + +namespace :doc do + begin + require 'yard' + rescue LoadError + # ignore + else + YARD::Rake::YardocTask.new do |task| + task.files = ["lib/**/*.rb", "-", "CHANGELOG.md", "LICENSE"] + task.options = [ + "--no-private", + "--protected", + "--output-dir", "doc/yard", + "--tag", "authenticated:Requires a user logged in", + "--tag", "admin:Requires an admin user logged in", + "--markup", "markdown", + ] + end + end +end \ No newline at end of file diff --git a/cloudfoundry.gemspec b/cloudfoundry.gemspec new file mode 100755 index 0000000..90afe63 --- /dev/null +++ b/cloudfoundry.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "cloudfoundry/version" + +Gem::Specification.new do |s| + s.name = "cloudfoundry-client" + s.version = CloudFoundry::Client::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["Ferran Rodenas"] + s.email = ["frodenas@gmail.com"] + s.homepage = "http://github.com/frodenas/cloudfoundry-client" + s.summary = %q{A Ruby wrapper for the CloudFoundry API PaaS} + s.description = %q{This is a Ruby wrapper for the CloudFoundry API, the industry’s first open Platform as a Service (PaaS) offering.} + s.licenses = ["MIT"] + + s.add_development_dependency("rspec", ">= 2.7.0") + s.add_development_dependency("webmock", ">= 1.7.8") + s.add_development_dependency("vcr", ">= 2.0.0.beta2") + + s.add_runtime_dependency("faraday", ">= 0.7.5") + s.add_runtime_dependency("json_pure", ">= 1.6.2") + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- spec/*`.split("\n") + s.require_paths = ["lib"] + + s.rdoc_options = ["--charset=UTF-8"] + s.extra_rdoc_files = ["CHANGELOG.md", "LICENSE", "README.md"] +end \ No newline at end of file diff --git a/lib/cloudfoundry.rb b/lib/cloudfoundry.rb new file mode 100755 index 0000000..7522973 --- /dev/null +++ b/lib/cloudfoundry.rb @@ -0,0 +1,34 @@ +require 'faraday' +require 'json/pure' + +# This is a Ruby wrapper for the CloudFoundry API, the industry’s first open Platform as a Service (PaaS) offering. +module CloudFoundry + require 'cloudfoundry/client' + require 'cloudfoundry/constants' + require 'cloudfoundry/exception' + require 'cloudfoundry/version' + + # @private + VERSION = CloudFoundry::Client::VERSION #:nodoc; + + class << self + # Alias for CloudFoundry::Client.new + # + # @return [CloudFoundry::Client] A CloudFoundry::Client Object. + # @see CloudFoundry::Client#initialize CloudFoundry::Client.new() + def new(options = {}) + CloudFoundry::Client.new(options) + end + + # Delegate all methods to CloudFoundry::Client. + def method_missing(method, *arguments, &block) + return super unless new.respond_to?(method) + new.send(method, *arguments, &block) + end + + # Delegate all methods to CloudFoundry::Client. + def respond_to?(method, include_private = false) + new.respond_to?(method, include_private) || super(method, include_private) + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client.rb b/lib/cloudfoundry/client.rb new file mode 100755 index 0000000..7cd6975 --- /dev/null +++ b/lib/cloudfoundry/client.rb @@ -0,0 +1,93 @@ +require 'cloudfoundry/client/apps' +require 'cloudfoundry/client/info' +require 'cloudfoundry/client/request' +require 'cloudfoundry/client/resources' +require 'cloudfoundry/client/response' +require 'cloudfoundry/client/services' +require 'cloudfoundry/client/users' + +module CloudFoundry + # This is a Ruby wrapper for the CloudFoundry API, the industry’s first open Platform as a Service (PaaS) offering. + class Client + include CloudFoundry::Client::Apps + include CloudFoundry::Client::Info + include CloudFoundry::Client::Request + include CloudFoundry::Client::Resources + include CloudFoundry::Client::Services + include CloudFoundry::Client::Users + + # Returns the HTTP connection adapter that will be used to connect. + attr_reader :net_adapter + # Returns the Proxy URL that will be used to connect. + attr_reader :proxy_url + # Returns the CloudFoundry API Target URL. + attr_reader :target_url + # Returns the CloudFoundry API Trace Key. + attr_reader :trace_key + # Returns the CloudFoundry API Authorization Token. + attr_reader :auth_token + # Returns the CloudFoundry Logged User. + attr_reader :user + # Returns the CloudFoundry Proxied User. + attr_reader :proxy_user + + # Creates a new CloudFoundry::Client object. + # + # @param [Hash] options + # @option options [Faraday::Adapter] :adapter The HTTP connection adapter that will be used to connect. + # @option options [String] :proxy_url The Proxy URL that will be used to connect. + # @option options [String] :target_url The CloudFoundry API Target URL. + # @option options [String] :trace_key The CloudFoundry API Trace Key. + # @option options [String] :auth_token The CloudFoundry API Authorization Token. + # @return [CloudFoundry::Client] A CloudFoundry::Client Object. + # @raise [CloudFoundry::Client::Exception::BadParams] when target_url is not a valid CloudFoundry API URL. + # @raise [CloudFoundry::Client::Exception::AuthError] when auth_token is not a valid CloudFoundry API authorization token. + def initialize(options = {}) + @net_adapter = options[:adapter] || DEFAULT_ADAPTER + @proxy_url = options[:proxy_url] || nil + @target_url = options[:target_url] || DEFAULT_TARGET + @target_url = sanitize_url(@target_url) + @trace_key = options[:trace_key] || nil + @auth_token = options[:auth_token] || nil + @user = nil + @proxy_user = nil + + raise CloudFoundry::Client::Exception::BadParams, "Invalid CloudFoundry API URL: " + @target_url unless valid_target_url? + if @auth_token + raise CloudFoundry::Client::Exception::AuthError, "Invalid CloudFoundry API authorization token" unless logged_in? + end + end + + private + + # Sanitizes an URL. + # + # @param [String] url URL to sanitize. + # @return [String] URL sanitized. + def sanitize_url(url) + url = url =~ /^(http|https).*/i ? url : "http://#{url}" + url = url.gsub(/\/+$/, "") + end + + # Checks if the target_url is a valid CloudFoundry target. + # + # @return [Boolean] Returns true if target_url is a valid CloudFoundry API URL, false otherwise. + def valid_target_url? + return false unless cloud_info = cloud_info() + return false unless cloud_info[:name] + return false unless cloud_info[:build] + return false unless cloud_info[:support] + return false unless cloud_info[:version] + true + rescue + false + end + + # Requires a logged in user. + # + # @raise [CloudFoundry::Client::Exception::AuthError] if user is not logged in. + def require_login + raise CloudFoundry::Client::Exception::AuthError unless @user || logged_in? + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/apps.rb b/lib/cloudfoundry/client/apps.rb new file mode 100755 index 0000000..494ebd0 --- /dev/null +++ b/lib/cloudfoundry/client/apps.rb @@ -0,0 +1,192 @@ +module CloudFoundry + class Client + # CloudFoundry API Applications methods. + module Apps + # Returns the list of applications deployed on the target cloud. + # + # @return [Hash] List of applications deployed on the target cloud. + # @authenticated True + def list_apps() + require_login + get(CloudFoundry::Client::APPS_PATH) + end + + # Returns basic information about an application deployed on the target cloud. + # + # @param [String] name The application name. + # @return [Hash] Basic application information on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def app_info(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + get("#{CloudFoundry::Client::APPS_PATH}/#{name}") + end + + # Returns information about application instances on the target cloud. + # + # @param [String] name The application name. + # @return [Hash] Application instances information on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def app_instances(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + get("#{CloudFoundry::Client::APPS_PATH}/#{name}/instances") + end + + # Returns information about application statistics on the target cloud. + # + # @param [String] name The application name. + # @return [Hash] Application statistics information on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def app_stats(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + stats = [] + stats_raw = get("#{CloudFoundry::Client::APPS_PATH}/#{name}/stats") + stats_raw.each_pair do |key, entry| + next unless entry[:stats] + entry[:instance] = key.to_s.to_i + entry[:state] = entry[:state].to_sym if entry[:state] + stats << entry + end + stats.sort { |a,b| a[:instance] - b[:instance] } + end + + # Returns information about application crashes on the target cloud. + # + # @param [String] name The application name. + # @return [Hash] Application crashes information on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def app_crashes(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + get("#{CloudFoundry::Client::APPS_PATH}/#{name}/crashes") + end + + # List the directory or a file indicated by the path and instance. + # + # @param [String] name The application name. + # @param [String] path The application directory or file to display. + # @param [Integer] instance The application instance where directories or files are located. + # @return [String] Directory list or file bits on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def app_files(name, path = "/", instance = 0) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + url = "#{CloudFoundry::Client::APPS_PATH}/#{name}/instances/#{instance}/files/#{path}" + url.gsub!('//', '/') + response_info = get(url, :raw => true) + response_info.body + end + + # Creates a new application at target cloud. + # + # @param [String] name The application name. + # @param [Hash] manifest The manifest of the application. + # @return [Boolean] Returns true if application is created. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when application manifest is blank. + # @authenticated True + def create_app(name, manifest = {}) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + raise CloudFoundry::Client::Exception::BadParams, "Manifest cannot be blank" if manifest.nil? || manifest.empty? + app = manifest.dup + app[:name] = name + app[:instances] ||= 1 + post(CloudFoundry::Client::APPS_PATH, app) + true + end + + # Updates an application at target cloud. + # + # @param [String] name The application name. + # @param [Hash] manifest The manifest of the application. + # @return [Boolean] Returns true if application is updated. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when application manifest is blank. + # @authenticated True + def update_app(name, manifest = {}) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + raise CloudFoundry::Client::Exception::BadParams, "Manifest cannot be blank" if manifest.nil? || manifest.empty? + put("#{CloudFoundry::Client::APPS_PATH}/#{name}", manifest) + true + end + + # Checks the status of the latest application update at target cloud. + # + # @param [String] name The application name. + # @return [Hash] Status of the latest application update at target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def update_app_info(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + get("#{CloudFoundry::Client::APPS_PATH}/#{name}/update") + end + + # Deletes an application at target cloud. + # + # @param [String] name The application name. + # @return [Boolean] Returns true if application is deleted. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def delete_app(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + delete("#{CloudFoundry::Client::APPS_PATH}/#{name}", :raw => true) + true + end + + # Uploads the application bits to the target cloud. + # + # @param [String] name The application name. + # @param [File, String] zipfile The application bits, can be a File Object or a filename String. + # @param [Array] resource_manifest The application resources manifest. + # @return [Boolean] Returns true if application is uploaded. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when application zipfile is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when application zipfile is invalid. + # @authenticated True + def upload_app(name, zipfile, resource_manifest = []) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + raise CloudFoundry::Client::Exception::BadParams, "Zipfile cannot be blank" if zipfile.nil? + upload_data = {} + begin + if zipfile.is_a? File + file = Faraday::UploadIO.new(zipfile, "application/zip") + else + filebits = File.new(zipfile, "rb") + file = Faraday::UploadIO.new(filebits, "application/zip") + end + rescue SystemCallError => error + raise CloudFoundry::Client::Exception::BadParams, "Invalid Zipfile: " + error.message + end + upload_data[:application] = file + upload_data[:resources] = resource_manifest.to_json if resource_manifest + put("#{CloudFoundry::Client::APPS_PATH}/#{name}/application", upload_data, :raw => true) + true + end + + # Downloads the application bits from the target cloud. + # + # @param [String] name The application name. + # @return [String] Application bits. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def download_app(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + response_info = get("#{CloudFoundry::Client::APPS_PATH}/#{name}/application", :raw => true) + response_info.body + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/info.rb b/lib/cloudfoundry/client/info.rb new file mode 100755 index 0000000..2175bb8 --- /dev/null +++ b/lib/cloudfoundry/client/info.rb @@ -0,0 +1,29 @@ +module CloudFoundry + class Client + # CloudFoundry API Info methods. + module Info + # Returns information about the target cloud and, if logged, information about the user account. + # + # @return [Hash] Information about the target cloud and, if logged, information about the user account. + def cloud_info() + get(CloudFoundry::Client::CLOUD_INFO_PATH) + end + + # Returns information about system runtimes that are available on the target cloud. + # + # @return [Hash] System Runtimes available on the target cloud. + def cloud_runtimes_info() + get(CloudFoundry::Client::CLOUD_RUNTIMES_INFO_PATH) + end + + # Returns information about system services that are available on the target cloud. + # + # @return [Hash] System Services available on the target cloud. + # @authenticated True + def cloud_services_info() + require_login + get(CloudFoundry::Client::CLOUD_SERVICES_INFO_PATH) + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/request.rb b/lib/cloudfoundry/client/request.rb new file mode 100755 index 0000000..50458c9 --- /dev/null +++ b/lib/cloudfoundry/client/request.rb @@ -0,0 +1,89 @@ +module CloudFoundry + class Client + # CloudFoundry API Request Methods. + module Request + + # Performs an HTTP GET request to the target cloud. + # + # @param [String] path Path to request at target cloud. + # @param [Hash] options + # @option options [Boolean] :raw true if response must not be parsed. + def get(path, options = {}) + request(:get, path, options) + end + + # Performs an HTTP POST request to the target cloud. + # + # @param [String] path Path to request at target cloud. + # @param [Hash] body Body of the request to the target cloud. + # @param [Hash] options + # @option options [Boolean] :raw true if response must not be parsed. + def post(path, body = {}, options = {}) + request(:post, path, options, body) + end + + # Performs an HTTP PUT request to the target cloud. + # + # @param [String] path Path to request at target cloud. + # @param [Hash] body Body of the request to the target cloud. + # @param [Hash] options + # @option options [Boolean] :raw true if response must not be parsed. + def put(path, body = {}, options = {}) + request(:put, path, options, body) + end + + # Performs an HTTP DELETE request to the target cloud. + # + # @param [String] path Path to request at target cloud. + # @param [Hash] options + # @option options [Boolean] :raw true if response must not be parsed. + def delete(path, options = {}) + request(:delete, path, options) + end + + private + + # Sets a new connection to target cloud. + # + # @param [Hash] options + # @option options [Boolean] :raw true if response must not be parsed. + # @return [Faraday::Connection] A Faraday Connection. + def connection(options = {}) + connection_options = { + :proxy => @proxy_url, + :url => @target_url + } + connection = Faraday.new(connection_options) do |builder| + builder.use Faraday::Request::Multipart + builder.use Faraday::Request::UrlEncoded + builder.use Faraday::Request::JSON unless options[:raw] + builder.adapter @net_adapter + builder.use CloudFoundry::Client::Response::ParseJSON unless options[:raw] + builder.use CloudFoundry::Client::Response::CloudError + end + end + + # Performs a request to the target cloud. + # + # @param [Symbol] method HTTP method to use. + # @param [String] path Path to request at target cloud. + # @param [Hash] options + # @param [Hash] payload Body of the request to the target cloud. + # @option options [Boolean] :raw true if response must not be parsed. + def request(method, path, options = {}, payload = nil) + headers = {} + headers["User-Agent"] = "cloudfoundry-client-" + CloudFoundry::Client::VERSION + headers["AUTHORIZATION"] = @auth_token if @auth_token + headers["PROXY-USER"] = @proxy_user if @proxy_user + headers["X-VCAP-Trace"] = @trace_key if @trace_key + headers["Accept"] = "application/json" unless options[:raw] + headers["Content-Type"] = "application/json" unless options[:raw] + response = connection(options).send(method, path) do |request| + request.headers = headers + request.body = payload unless payload && payload.empty? + end + options[:raw] ? response : response.body + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/resources.rb b/lib/cloudfoundry/client/resources.rb new file mode 100644 index 0000000..671f303 --- /dev/null +++ b/lib/cloudfoundry/client/resources.rb @@ -0,0 +1,16 @@ +module CloudFoundry + class Client + # CloudFoundry API Resources methods. + module Resources + # Checks which resources are needed to send to the target cloud when uploading application bits. + # + # @param [Array] resources A resources manifest. + # @return [Array] A resources manifest. + # @authenticated True + def check_resources(resources) + require_login + post(CloudFoundry::Client::RESOURCES_PATH, resources) + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/response.rb b/lib/cloudfoundry/client/response.rb new file mode 100644 index 0000000..e17858c --- /dev/null +++ b/lib/cloudfoundry/client/response.rb @@ -0,0 +1,68 @@ +module CloudFoundry + class Client + # CloudFoundry Faraday Response Middleware. + module Response + # Faraday Response Middleware to parse cloud JSON responses. + class ParseJSON < Faraday::Response::Middleware + # Parses a JSON response. + # + # @param [String] body HTTP body response. + # @return [Hash] Parsed body response with symbolized names (keys). + # @raise [CloudFoundry::Client::Exception::BadResponse] when body can not be parsed. + def parse(body) + case body + when " " then nil + else JSON.parse(body, :symbolize_names => true) + end + rescue JSON::ParserError + raise CloudFoundry::Client::Exception::BadResponse, "Can't parse response into JSON:" + body + end + end + + # Faraday Response Middleware to parse cloud errors. + class CloudError < Faraday::Response::Middleware + # Checks if an error is returned by target cloud. + # + # @param [Hash] env Faraday environment. + # @raise [CloudFoundry::Client::Exception::BadRequest] when HTTP status is 400. + # @raise [CloudFoundry::Client::Exception::Forbidden] when HTTP status is 403. + # @raise [CloudFoundry::Client::Exception::NotFound] when HTTP status is 404. + # @raise [CloudFoundry::Client::Exception::ServerError] when HTTP status is 500. + # @raise [CloudFoundry::Client::Exception::BadGateway] when HTTP status is 502. + def on_complete(env) + if env[:status].to_i >= 400 + err = case env[:status].to_i + when 400 then CloudFoundry::Client::Exception::BadRequest + when 403 then CloudFoundry::Client::Exception::Forbidden + when 404 then CloudFoundry::Client::Exception::NotFound + when 500 then CloudFoundry::Client::Exception::ServerError + when 502 then CloudFoundry::Client::Exception::BadGateway + end + raise err, parse_cloud_error_message(env[:status], env[:body]) + end + end + + # Parses a CloudFoundry error message. + # + # @param [String] status Faraday HTTP response status. + # @param [String] body Faraday HTTP response body. + # @return [String] CloudFoundry error message. + def parse_cloud_error_message(status, body) + parsed_body = JSON.parse(body, :symbolize_names => true) + if parsed_body && parsed_body[:code] && parsed_body[:description] + description = parsed_body[:description].gsub("\"","'") + "Error #{parsed_body[:code]}: #{description}" + else + "Error (HTTP #{status}): #{body}" + end + rescue JSON::ParserError + if body.nil? || body.empty? + "Error (#{status}): No Response Received" + else + "Error (JSON #{status}): #{body}" + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/services.rb b/lib/cloudfoundry/client/services.rb new file mode 100755 index 0000000..f25750b --- /dev/null +++ b/lib/cloudfoundry/client/services.rb @@ -0,0 +1,122 @@ +module CloudFoundry + class Client + # CloudFoundry API Provisioned Services methods. + module Services + # Returns a list of provisioned services that are available on the target cloud. + # + # @return [Hash] List of provisioned services available on the target cloud. + # @authenticated True + def list_services + require_login + get(CloudFoundry::Client::SERVICES_PATH) + end + + # Returns information about a provisioned service on the target cloud. + # + # @param [String] name The provisioned service name. + # @return [Hash] Provisioned service information on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service name is blank. + # @authenticated True + def service_info(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + get("#{CloudFoundry::Client::SERVICES_PATH}/#{name}") + end + + # Creates a new provisioned service on the target cloud. + # + # @param [String] service The system service to provision. + # @param [String] name The provisioned service name. + # @return [Boolean] Returns true if provisioned service is created. + # @raise [CloudFoundry::Client::Exception::BadParams] when system service is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when system service is not a valid service at target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service name is blank. + # @authenticated True + def create_service(service, name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Service cannot be blank" if service.nil? || service.empty? + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + service_hash = nil + services = cloud_services_info() || [] + services.each do |service_type, service_value| + service_value.each do |vendor, vendor_value| + vendor_value.each do |version, service_info| + if service == service_info[:vendor] + service_hash = { + :type => service_info[:type], + :vendor => vendor, + :version => version, + :tier => "free" + } + break + end + end + end + end + raise CloudFoundry::Client::Exception::BadParams, "Service [#{service}] is not a valid service" unless service_hash + service_hash[:name] = name + post(CloudFoundry::Client::SERVICES_PATH, service_hash) + true + end + + # Deletes a provisioned service on the target cloud. + # + # @param [String] name The provisioned service name. + # @return [Boolean] Returns true if provisioned service is deleted. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service name is blank. + # @authenticated True + def delete_service(name) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Name cannot be blank" if name.nil? || name.empty? + delete("#{CloudFoundry::Client::SERVICES_PATH}/#{name}", :raw => true) + true + end + + # Binds a provisioned service to an application on the target cloud. + # + # @param [String] name The provisioned service name. + # @param [String] appname The application name. + # @return [Boolean] Returns true if provisioned service is binded to application. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service name is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service is already binded to application. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def bind_service(name, appname) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Service Name cannot be blank" if name.nil? || name.empty? + raise CloudFoundry::Client::Exception::BadParams, "Application Name cannot be blank" if appname.nil? || appname.empty? + service = service_info(name) + app = app_info(appname) + services = app[:services] || [] + service_exists = services.index(name) + raise CloudFoundry::Client::Exception::BadParams, "Service [#{name}] is already binded to [#{appname}]" if service_exists + app[:services] = services << name + update_app(appname, app) + true + end + + # Unbinds a provisioned service from an application on the target cloud. + # + # @param [String] name The provisioned service name. + # @param [String] appname The application name. + # @return [Boolean] Returns true if provisioned service is unbinded from application. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service name is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when provisioned service is not binded to application. + # @raise [CloudFoundry::Client::Exception::BadParams] when application name is blank. + # @authenticated True + def unbind_service(name, appname) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Service Name cannot be blank" if name.nil? || name.empty? + raise CloudFoundry::Client::Exception::BadParams, "Application Name cannot be blank" if appname.nil? || appname.empty? + service = service_info(name) + app = app_info(appname) + services = app[:services] || [] + service_deleted = services.delete(name) + raise CloudFoundry::Client::Exception::BadParams, "Service [#{name}] is not binded to [#{name}]" unless service_deleted + app[:services] = services + update_app(appname, app) + true + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/client/users.rb b/lib/cloudfoundry/client/users.rb new file mode 100755 index 0000000..27d7173 --- /dev/null +++ b/lib/cloudfoundry/client/users.rb @@ -0,0 +1,121 @@ +module CloudFoundry + class Client + # CloudFoundry API Users methods. + module Users + # Logs the user in and returns the auth_token provided by the target cloud. + # + # @param [String] email The user's email. + # @param [String] password The user's password. + # @return [String] CloudFoundry API Authorization Token. + # @raise [CloudFoundry::Client::Exception::BadParams] when email is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when password is blank. + # @raise [CloudFoundry::Client::Exception::Forbidden] when login fails. + def login(email, password) + raise CloudFoundry::Client::Exception::BadParams, "Email cannot be blank" if email.nil? || email.empty? + raise CloudFoundry::Client::Exception::BadParams, "Password cannot be blank" if password.nil? || password.empty? + response_info = post("#{CloudFoundry::Client::USERS_PATH}/#{email}/tokens", {:password => password}) + raise CloudFoundry::Client::Exception::Forbidden, "Login failed" unless response_info && response_info[:token] + @user = email + @proxy_user = nil + @auth_token = response_info[:token] + end + + # Checks if the user is logged in at the cloud target. + # + # @return [Boolean] Returns true if user is logged in, false otherwise. + def logged_in? + return false unless cloud_info = cloud_info() + return false unless cloud_info[:user] + return false unless cloud_info[:usage] + @user = cloud_info[:user] + true + end + + # Sets a user proxied access + # + # @param [String] email The user's email to be proxied. + # @return [String] Proxied user. + # @raise [CloudFoundry::Client::Exception::BadParams] when email is blank. + # @admin True + def set_proxy_user(email) + raise CloudFoundry::Client::Exception::BadParams, "Email cannot be blank" if email.nil? || email.empty? + @proxy_user = email + end + + # Unsets a user proxied access + # + # @return [nil] + def unset_proxy_user() + @proxy_user = nil + end + + # Returns the list of users on the target cloud. + # + # @return [Hash] List of users on the target cloud. + # @admin True + def list_users() + require_login + get(CloudFoundry::Client::USERS_PATH) + end + + # Returns information about a user on the target cloud. + # + # @param [String] email The user's email. + # @return [Hash] User information on the target cloud. + # @raise [CloudFoundry::Client::Exception::BadParams] when email is blank. + # @authenticated True + # @admin Only when retrieving information about others users. + def user_info(email) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Email cannot be blank" if email.nil? || email.empty? + get("#{CloudFoundry::Client::USERS_PATH}/#{email}") + end + + # Creates a new user on the target cloud. + # + # @param [String] email The user's email. + # @param [String] password The user's password. + # @return [Boolean] Returns true if user is created. + # @raise [CloudFoundry::Client::Exception::BadParams] when email is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when password is blank. + def create_user(email, password) + raise CloudFoundry::Client::Exception::BadParams, "Email cannot be blank" if email.nil? || email.empty? + raise CloudFoundry::Client::Exception::BadParams, "Password cannot be blank" if password.nil? || password.empty? + post(CloudFoundry::Client::USERS_PATH, {:email => email, :password => password}) + true + end + + # Updates the user's password on the target cloud. + # + # @param [String] email The user's email. + # @param [String] password The user's password. + # @return [Boolean] Returns true if user is updated. + # @raise [CloudFoundry::Client::Exception::BadParams] when email is blank. + # @raise [CloudFoundry::Client::Exception::BadParams] when password is blank. + # @authenticated True + # @admin Only when updating password for others users. + def update_user(email, password) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Email cannot be blank" if email.nil? || email.empty? + raise CloudFoundry::Client::Exception::BadParams, "Password cannot be blank" if password.nil? || password.empty? + user_info = user_info(email) + user_info[:password] = password + put("#{CloudFoundry::Client::USERS_PATH}/#{email}", user_info) + true + end + + # Deletes a user on the target cloud. + # + # @param [String] email The user's email. + # @return [Boolean] Returns true if user is deleted. + # @raise [CloudFoundry::Client::Exception::BadParams] when email is blank. + # @admin True + def delete_user(email) + require_login + raise CloudFoundry::Client::Exception::BadParams, "Email cannot be blank" if email.nil? || email.empty? + delete("#{CloudFoundry::Client::USERS_PATH}/#{email}", :raw => true) + true + end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/constants.rb b/lib/cloudfoundry/constants.rb new file mode 100755 index 0000000..d57c69c --- /dev/null +++ b/lib/cloudfoundry/constants.rb @@ -0,0 +1,30 @@ +module CloudFoundry + class Client + # The HTTP connection adapter that will be used to connect if none is set. + DEFAULT_ADAPTER = :net_http + + # Default CloudFoundry API Target URL. + DEFAULT_TARGET = "http://api.vcap.me" + + # CloudFoundry API Info Path. + CLOUD_INFO_PATH = "/info" + + # CloudFoundry API System Services Info Path. + CLOUD_SERVICES_INFO_PATH = "/info/services" + + # CloudFoundry API Runtimes Info Path. + CLOUD_RUNTIMES_INFO_PATH = "/info/runtimes" + + # CloudFoundry API Applications Path. + APPS_PATH = "/apps" + + # CloudFoundry API Resources Path. + RESOURCES_PATH = "/resources" + + # CloudFoundry API Services Path. + SERVICES_PATH = "/services" + + # CloudFoundry API Users Path. + USERS_PATH = "/users" + end +end diff --git a/lib/cloudfoundry/exception.rb b/lib/cloudfoundry/exception.rb new file mode 100755 index 0000000..057d2bd --- /dev/null +++ b/lib/cloudfoundry/exception.rb @@ -0,0 +1,24 @@ +module CloudFoundry + class Client + # CloudFoundry::Client Exceptions. + module Exception + # CloudFoundry Client Exception: Authorization Error. + class AuthError < RuntimeError; end + # CloudFoundry Client Exception: Bad Parameters. + class BadParams < RuntimeError; end + # CloudFoundry Client Exception: Bad Response Received. + class BadResponse < RuntimeError; end + + # CloudFoundry Cloud Exception: Bad Request. + class BadRequest < RuntimeError; end + # CloudFoundry Cloud Exception: Forbidden. + class Forbidden < RuntimeError; end + # CloudFoundry Cloud Exception: Not Found. + class NotFound < RuntimeError; end + # CloudFoundry Cloud Exception: Server Error. + class ServerError < RuntimeError; end + # CloudFoundry Cloud Exception: Bad Gateway. + class BadGateway < RuntimeError; end + end + end +end \ No newline at end of file diff --git a/lib/cloudfoundry/version.rb b/lib/cloudfoundry/version.rb new file mode 100755 index 0000000..ea8925f --- /dev/null +++ b/lib/cloudfoundry/version.rb @@ -0,0 +1,27 @@ +module CloudFoundry + class Client + + # Major CloudFoundry::Client Version. + def self.major + 0 + end + + # Minor CloudFoundry::Client Version. + def self.minor + 1 + end + + # Patch CloudFoundry::Client Version. + def self.patch + 0 + end + + # Pre CloudFoundry::Client Version. + def self.pre + nil + end + + # CloudFoundry::Client Version. + VERSION = [major, minor, patch, pre].compact.join(".") + end +end \ No newline at end of file diff --git a/spec/client/apps_spec.rb b/spec/client/apps_spec.rb new file mode 100755 index 0000000..4f4b349 --- /dev/null +++ b/spec/client/apps_spec.rb @@ -0,0 +1,423 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "Cloudfoundry::Client::Apps" do + include CfConnectionHelper + + context "without a user logged in" do + before(:all) do + VCR.use_cassette("no_logged/client", :record => :new_episodes) do + @cf_client = client_no_logged() + end + end + + use_vcr_cassette "no_logged/apps", :record => :new_episodes + + it "should raise an AuthError exception when creating an application" do + expect { + created = @cf_client.create_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when listing all applications at target cloud" do + expect { + apps = @cf_client.list_apps() + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving basic application information from target cloud" do + expect { + app_info = @cf_client.app_info("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving application instances information from target cloud" do + expect { + app_instances = @cf_client.app_instances("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving application stats information from target cloud" do + expect { + app_stats = @cf_client.app_stats("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving application crashes information from target cloud" do + expect { + app_crashes = @cf_client.app_crashes("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving application files information from target cloud" do + expect { + app_files = @cf_client.app_files("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when updating an application at target cloud" do + expect { + updated = @cf_client.update_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving application update status information from target cloud" do + expect { + update_info = @cf_client.update_app_info("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when uploading application bits to target cloud" do + expect { + appfile = spec_fixture("app.zip") + upload = @cf_client.upload_app("newapp", appfile) + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when application bits at target cloud" do + expect { + appbits = @cf_client.download_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when deleting an application at target cloud" do + expect { + deleted = @cf_client.delete_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + end + + context "with a user logged in" do + before(:all) do + VCR.use_cassette("user_logged/client", :record => :new_episodes) do + @cf_client = client_user_logged() + end + end + + use_vcr_cassette "user_logged/apps", :record => :new_episodes + + it "should raise a BadParams exception when creating an application with a blank application name" do + expect { + created = @cf_client.create_app("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when creating an application with no manifest" do + expect { + created = @cf_client.create_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadRequest exception when creating an application with an invalid manifest" do + expect { + manifest = { + :name => "newapp", + } + created = @cf_client.create_app("newapp", manifest) + }.to raise_exception(CloudFoundry::Client::Exception::BadRequest) + end + + it "should return true if a new application is created at target cloud" do + VCR.use_cassette("user_logged/apps_create_action", :record => :new_episodes, :exclusive => true) do + manifest = { + :name => "newapp", + :uris => ["newapp.vcap.me"], + :instances => 1, + :staging => {:model => "node"}, + :resources => {:memory => 64} + } + created = @cf_client.create_app("newapp", manifest) + created.should be_true + end + end + + it "should get a proper list of apps at target cloud" do + apps = @cf_client.list_apps() + apps.should have_at_least(1).items + app_info = apps.first + app_info.should have_key :name + app_info.should have_key :staging + app_info.should have_key :uris + app_info.should have_key :instances + app_info.should have_key :runningInstances + app_info.should have_key :resources + app_info.should have_key :state + app_info.should have_key :services + app_info.should have_key :version + app_info.should have_key :env + app_info.should have_key :meta + end + + it "should raise an BadParams exception when retrieving basic information with blank application name" do + expect { + app_info = @cf_client.app_info("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise an NotFound exception when retrieving basic information for an application that does not exists at target cloud" do + expect { + app_info = @cf_client.app_info("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should properly get basic application information from target cloud" do + app_info = @cf_client.app_info("newapp") + app_info.should have_key :name + app_info.should have_key :staging + app_info.should have_key :uris + app_info.should have_key :instances + app_info.should have_key :runningInstances + app_info.should have_key :resources + app_info.should have_key :state + app_info.should have_key :services + app_info.should have_key :version + app_info.should have_key :env + app_info.should have_key :meta + end + + it "should raise an BadParams exception when retrieving instances information with blank application name" do + expect { + app_instances = @cf_client.app_instances("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise an NotFound exception when retrieving instances information for an application that does not exists at target cloud" do + expect { + app_instances = @cf_client.app_instances("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should properly get application instances information from target cloud" do + app_instances = @cf_client.app_instances("newapp") + app_instances.should have_key :instances + end + + it "should raise an BadParams exception when retrieving stats information with blank application name" do + expect { + app_stats = @cf_client.app_stats("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise an NotFound exception when retrieving stats information for an application that does not exists at target cloud" do + expect { + app_stats = @cf_client.app_stats("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should properly get empty application stats information from target cloud" do + app_stats = @cf_client.app_stats("newapp") + app_stats.should be_empty + end + + it "should raise an BadParams exception when retrieving crashes information with blank application name" do + expect { + app_crashes = @cf_client.app_crashes("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise an NotFound exception when retrieving crashes information for an application that does not exists at target cloud" do + expect { + app_crashes = @cf_client.app_crashes("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should properly get application crashes information from target cloud" do + app_crashes = @cf_client.app_crashes("newapp") + app_crashes.should have_key :crashes + end + + it "should raise an BadParams exception when retrieving files information with blank application name" do + expect { + app_files = @cf_client.app_files("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise an NotFound exception when retrieving files information for an application that does not exists at target cloud" do + expect { + app_files = @cf_client.app_files("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should raise an BadRequest exception when retrieving files information for an application without bits at target cloud" do + expect { + app_files = @cf_client.app_files("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::BadRequest) + end + + it "should raise a BadParams exception when updating an application with a blank name" do + expect { + updated = @cf_client.update_app("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when updating an application with no manifest" do + expect { + updated = @cf_client.update_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when updating an application that does not exists at target cloud" do + expect { + manifest = { + :name => "noapp", + } + updated = @cf_client.update_app("noapp", manifest) + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should return true if an application is updated at target cloud" do + app_info = @cf_client.app_info("newapp") + app_info[:instances] = 2 + updated = @cf_client.update_app("newapp", app_info) + updated.should be_true + end + + it "should raise a BadParams exception when retrieving update status information with a blank name" do + expect { + update_info = @cf_client.update_app_info("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when retrieving application update status information for an application that does not exists at target cloud" do + expect { + update_info = @cf_client.update_app_info("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should raise a BadParams exception when uploading application bits with a blank name" do + expect { + upload = @cf_client.upload_app("", nil) + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when uploading application bits with a blank zipfile" do + expect { + upload = @cf_client.upload_app("newapp", nil) + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when uploading application bits with an invalid zipfile" do + expect { + upload = @cf_client.upload_app("newapp", "fakefile") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when uploading application bits for an application that does not exists at target cloud" do + expect { + appfile = spec_fixture("app.zip") + upload = @cf_client.upload_app("noapp", appfile) + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should raise a BadParams exception when downloading application bits with a blank name" do + expect { + appbits = @cf_client.download_app("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when downloading application bits for an application that does not exists at target cloud" do + expect { + appbits = @cf_client.download_app("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should raise a NotFound exception when downloading application bits for an application without bits at target cloud" do + expect { + appbits = @cf_client.download_app("newapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should return true if application bits passed as filename are uploaded to the target cloud" do + VCR.use_cassette("user_logged/apps_upload_filename_action", :record => :new_episodes, :exclusive => true) do + filename = spec_fixture("app.zip") + upload = @cf_client.upload_app("newapp", filename) + upload.should be_true + end + end + + it "should return true if application bits passed as file are uploaded to the target cloud" do + VCR.use_cassette("user_logged/apps_upload_zipfile_action", :record => :new_episodes, :exclusive => true) do + filename = spec_fixture("app.zip") + appfile = File.new(filename, "rb") + upload = @cf_client.upload_app("newapp", appfile) + upload.should be_true + end + end + + it "should return true if an application is started at target cloud" do + VCR.use_cassette("user_logged/apps_start_action", :record => :new_episodes, :exclusive => true) do + app_info = @cf_client.app_info("newapp") + app_info[:state] = "STARTED" + updated = @cf_client.update_app("newapp", app_info) + updated.should be_true + end + end + + it "should properly get application update status information from target cloud" do + VCR.use_cassette("user_logged/apps_update_info_action", :record => :new_episodes, :exclusive => true) do + update_info = @cf_client.update_app_info("newapp") + update_info.should have_key :state + update_info.should have_key :since + end + end + + it "should properly get application bits from target cloud" do + VCR.use_cassette("user_logged/apps_download_action", :record => :new_episodes, :exclusive => true) do + appbits = @cf_client.download_app("newapp") + appbits.should_not be_empty + end + end + + it "should properly get directory information for an application at target cloud" do + VCR.use_cassette("user_logged/apps_directory_action", :record => :new_episodes, :exclusive => true) do + app_files = @cf_client.app_files("newapp", "/app") + app_files.should include("app.js") + end + end + + it "should properly get file information for an application at target cloud" do + VCR.use_cassette("user_logged/apps_file_action", :record => :new_episodes, :exclusive => true) do + app_file = @cf_client.app_files("newapp", "/app/app.js") + filebits = "" + filename = spec_fixture("app.js") + appfile = File.new(filename, "r") + while (line = appfile.gets) + filebits += line + end + appfile.close + app_file.should eql(filebits) + end + end + + it "should raise an ServerError exception when retrieving files information for a file that does not exists at target cloud" do + expect { + app_files = @cf_client.app_files("newapp", "/app/nofile") + }.to raise_exception(CloudFoundry::Client::Exception::ServerError) + end + + it "should properly get application stats information from target cloud" do + VCR.use_cassette("user_logged/apps_stats_action", :record => :new_episodes, :exclusive => true) do + app_stats = @cf_client.app_stats("newapp") + app_stats.should have_at_least(1).items + app_stats_info = app_stats.first + app_stats_info.should have_key :stats + end + end + + it "should raise a BadParams exception when deleting an application with a blank name" do + expect { + deleted = @cf_client.delete_app("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when deleting an application that does not exists at target cloud" do + expect { + deleted = @cf_client.delete_app("noapp") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should return true if an application is deleted at target cloud" do + deleted = @cf_client.delete_app("newapp") + deleted.should be_true + end + end +end \ No newline at end of file diff --git a/spec/client/info_spec.rb b/spec/client/info_spec.rb new file mode 100755 index 0000000..822ca7d --- /dev/null +++ b/spec/client/info_spec.rb @@ -0,0 +1,92 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "Cloudfoundry::Client::Info" do + include CfConnectionHelper + + context "without a user logged in" do + before(:all) do + VCR.use_cassette("no_logged/client", :record => :new_episodes) do + @cf_client = client_no_logged() + end + end + + use_vcr_cassette "no_logged/info", :record => :new_episodes + + it "should properly get basic information from target cloud" do + cloud_info = @cf_client.cloud_info() + cloud_info.should have_key :name + cloud_info.should have_key :build + cloud_info.should have_key :support + cloud_info.should have_key :version + cloud_info.should have_key :description + cloud_info.should have_key :allow_debug + end + + it "should not return user account information from target cloud" do + cloud_info = @cf_client.cloud_info() + cloud_info.should_not have_key :user + cloud_info.should_not have_key :usage + cloud_info.should_not have_key :limits + end + + it "should get a proper list of runtimes available at target cloud" do + cloud_runtimes_info = @cf_client.cloud_runtimes_info() + cloud_runtimes_info.should have_at_least(1).items + runtime_info = cloud_runtimes_info.first[1] + runtime_info.should have_key :version + end + + it "should raise an AuthError exception when requesting system services" do + expect { + cloud_services_info = @cf_client.cloud_services_info() + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + end + + context "with a user logged in" do + before(:all) do + VCR.use_cassette("user_logged/client", :record => :new_episodes) do + @cf_client = client_user_logged() + end + end + + use_vcr_cassette "user_logged/info", :record => :new_episodes + + it "should properly get basic account information from target cloud" do + cloud_info = @cf_client.cloud_info() + cloud_info.should have_key :name + cloud_info.should have_key :build + cloud_info.should have_key :support + cloud_info.should have_key :version + cloud_info.should have_key :description + cloud_info.should have_key :allow_debug + end + + it "should properly get user account information from target cloud" do + cloud_info = @cf_client.cloud_info() + cloud_info.should have_key :user + cloud_info.should have_key :usage + cloud_info.should have_key :limits + cloud_info[:user].should eql(@user) + end + + it "should get a proper list of runtimes available at target cloud" do + cloud_runtimes_info = @cf_client.cloud_runtimes_info() + cloud_runtimes_info.should have_at_least(1).items + runtime_info = cloud_runtimes_info.first[1] + runtime_info.should have_key :version + end + + it "should get a proper list of system services available at target cloud" do + cloud_services_info = @cf_client.cloud_services_info() + cloud_services_info.should have_at_least(1).items + system_service_info = cloud_services_info.first[1].values[0].first[1] + system_service_info.should have_key :id + system_service_info.should have_key :type + system_service_info.should have_key :vendor + system_service_info.should have_key :version + system_service_info.should have_key :description + system_service_info.should have_key :tiers + end + end +end \ No newline at end of file diff --git a/spec/client/resources_spec.rb b/spec/client/resources_spec.rb new file mode 100644 index 0000000..1b1c0d4 --- /dev/null +++ b/spec/client/resources_spec.rb @@ -0,0 +1,52 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "Cloudfoundry::Client::Resources" do + include CfConnectionHelper + + context "without a user logged in" do + before(:all) do + VCR.use_cassette("no_logged/client", :record => :new_episodes) do + @cf_client = client_no_logged() + end + end + + use_vcr_cassette "no_logged/resources", :record => :new_episodes + + it "should raise an AuthError exception when checking resources at target cloud" do + expect { + resources = [] + resources_manifest = @cf_client.check_resources(resources) + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + end + + context "with a user logged in" do + before(:all) do + VCR.use_cassette("user_logged/client", :record => :new_episodes) do + @cf_client = client_user_logged() + end + end + + use_vcr_cassette "user_logged/resources", :record => :new_episodes + + it "should properly get an empty resources manifest file from target cloud" do + resources = [] + resources_manifest = @cf_client.check_resources(resources) + resources_manifest.should be_empty + end + + it "should properly get a resources manifest file from target cloud" do + VCR.use_cassette("user_logged/resources_check_action", :record => :new_episodes, :exclusive => true) do + resources = [] + filename = spec_fixture("app.js") + resources << { + :size => File.size(filename), + :sha1 => Digest::SHA1.file(filename).hexdigest, + :fn => filename + } + resources_manifest = @cf_client.check_resources(resources) + resources_manifest.should eql(resources) + end + end + end +end \ No newline at end of file diff --git a/spec/client/services_spec.rb b/spec/client/services_spec.rb new file mode 100755 index 0000000..afe390c --- /dev/null +++ b/spec/client/services_spec.rb @@ -0,0 +1,230 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "Cloudfoundry::Client::Services" do + include CfConnectionHelper + + context "without a user logged in" do + before(:all) do + VCR.use_cassette("no_logged/client", :record => :new_episodes) do + @cf_client = client_no_logged() + end + end + + use_vcr_cassette "no_logged/services", :record => :new_episodes + + it "should raise an AuthError exception when creating a provisioned service" do + expect { + created = @cf_client.create_service("redis", "redis-mock") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when listing provisioned services at target cloud" do + expect { + services = @cf_client.list_services() + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving provisioned service information from target cloud" do + expect { + service_info = @cf_client.service_info("redis-mock") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when binding a provisioned service to an application at target cloud" do + expect { + binded = @cf_client.bind_service("redis-mock", "newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when unbinding a provisioned service to an application at target cloud" do + expect { + unbinded = @cf_client.unbind_service("redis-mock", "newapp") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when deleting a provisioned service at target cloud" do + expect { + deleted = @cf_client.delete_service("redis-mock") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + end + + context "with a user logged in" do + before(:all) do + VCR.use_cassette("user_logged/client", :record => :new_episodes) do + @cf_client = client_user_logged() + end + end + + use_vcr_cassette "user_logged/services", :record => :new_episodes + + it "should raise a BadParams exception when creating a provisioned service with a blank system service" do + expect { + created = @cf_client.create_service("", "redis-mock") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when creating a provisioned service with a blank name" do + expect { + created = @cf_client.create_service("redis", "") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when creating a provisioned service with an invalid system service" do + expect { + created = @cf_client.create_service("noservice", "redis-mock") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should return true if a new provisioned service is created at target cloud" do + VCR.use_cassette("user_logged/services_create_action", :record => :new_episodes, :exclusive => true) do + created = @cf_client.create_service("redis", "redis-mock") + created.should be_true + end + end + + it "should raise a BadRequest exception when creating a provisioned service that already exists at target cloud" do + expect { + created = @cf_client.create_service("redis", "redis-mock") + }.to raise_exception(CloudFoundry::Client::Exception::BadRequest) + end + + it "should get a proper list of provisioned services at target cloud" do + services = @cf_client.list_services() + services.should have_at_least(1).items + service_info = services.first + service_info.should have_key :type + service_info.should have_key :vendor + service_info.should have_key :name + service_info.should have_key :version + service_info.should have_key :tier + service_info.should have_key :meta + service_info.should have_key :properties + end + + it "should raise a BadParams exception when retrieving information about a provisioned service with a blank name" do + expect { + service_info = @cf_client.service_info("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when retrieving information about a provisioned service that does not exists at target cloud" do + expect { + service_info = @cf_client.service_info("noservice") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should properly get provisioned service information from target cloud" do + service_info = @cf_client.service_info("redis-mock") + service_info.should have_key :type + service_info.should have_key :vendor + service_info.should have_key :name + service_info.should have_key :version + service_info.should have_key :tier + service_info.should have_key :meta + service_info.should have_key :properties + end + + it "should raise a BadParams exception when binding to an application a provisioned service with a blank name" do + expect { + binded = @cf_client.bind_service("", "appname") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when binding a provisioned service to an application with a blank name" do + expect { + binded = @cf_client.bind_service("redis-mock", "") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when binding to an application a provisioned service that does not exists" do + expect { + binded = @cf_client.bind_service("noservice", "appname") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should raise a NotFound exception when binding a provisioned service to an application that does not exists" do + expect { + binded = @cf_client.bind_service("redis-mock", "appname") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should return true if a provisioned service is binded to an application at target cloud" do + VCR.use_cassette("user_logged/services_bind_action", :record => :new_episodes, :exclusive => true) do + manifest = { + :name => "newapp", + :uris => ["newapp.vcap.me"], + :instances => 1, + :staging => {:model => "node"}, + :resources => {:memory => 64} + } + created = @cf_client.create_app("newapp", manifest) + binded = @cf_client.bind_service("redis-mock", "newapp") + binded.should be_true + end + end + + it "should raise a BadParams exception when binding a provisioned service to an application already binded" do + expect { + binded = @cf_client.bind_service("redis-mock", "newapp") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when unbinding from an application a provisioned service with a blank name" do + expect { + unbinded = @cf_client.unbind_service("", "appname") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when unbinding a provisioned service from an application with a blank name" do + expect { + unbinded = @cf_client.unbind_service("redis-mock", "") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when unbinding a provisioned service that does not exists from an application" do + expect { + unbinded = @cf_client.unbind_service("noservice", "appname") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should raise a NotFound exception when unbinding a provisioned service from an application that does not exists" do + expect { + unbinded = @cf_client.unbind_service("redis-mock", "appname") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should return true if a provisioned service is binded to an application at target cloud" do + VCR.use_cassette("user_logged/services_unbind_action", :record => :new_episodes, :exclusive => true) do + unbinded = @cf_client.unbind_service("redis-mock", "newapp") + unbinded.should be_true + end + end + + it "should raise a BadParams exception when unbinding a provisioned service from an application that is not binded" do + VCR.use_cassette("user_logged/services_unbind_fail_action", :record => :new_episodes, :exclusive => true) do + expect { + unbinded = @cf_client.unbind_service("redis-mock", "newapp") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + deleted = @cf_client.delete_app("newapp") + end + end + + it "should raise a BadParams exception when deleting a provisioned service with a blank name" do + expect { + deleted = @cf_client.delete_service("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a NotFound exception when deleting a provisioned service that does not exists at target cloud" do + expect { + deleted = @cf_client.delete_service("noservice") + }.to raise_exception(CloudFoundry::Client::Exception::NotFound) + end + + it "should return true if a provisioned service is deleted at target cloud" do + deleted = @cf_client.delete_service("redis-mock") + deleted.should be_true + end + end +end \ No newline at end of file diff --git a/spec/client/users_spec.rb b/spec/client/users_spec.rb new file mode 100755 index 0000000..c063be9 --- /dev/null +++ b/spec/client/users_spec.rb @@ -0,0 +1,367 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "Cloudfoundry::Client::Users" do + include CfConnectionHelper + + context "without a user logged in" do + before(:all) do + VCR.use_cassette("no_logged/client", :record => :new_episodes) do + @cf_client = client_no_logged() + end + end + + use_vcr_cassette "no_logged/users", :record => :new_episodes + + it "should return true if a new user is created at target cloud" do + created = @cf_client.create_user("fakeuser1@vcap.me", "foobar") + created.should be_true + end + + it "should raise an AuthError exception when listing all users at target cloud" do + expect { + users = @cf_client.list_users() + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when retrieving user information from target cloud" do + expect { + user_info = @cf_client.user_info("user@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when updating a user at target cloud" do + expect { + updated = @cf_client.update_user("user@vcap.me", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should raise an AuthError exception when deleting a user at target cloud" do + expect { + deleted = @cf_client.delete_user("user@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + + it "should allow to proxy a user" do + proxied_user = @cf_client.set_proxy_user("user@vcap.me") + proxied_user.should eql("user@vcap.me") + proxied_user.should eql(@cf_client.proxy_user) + end + + it "should raise a Forbidden exception when retrieving proxy user account information from target cloud" do + VCR.use_cassette("no_logged/users_proxy_action", :record => :new_episodes, :exclusive => true) do + expect { + proxied_user = @cf_client.set_proxy_user("user@vcap.me") + cloud_info = @cf_client.cloud_info() + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + end + + it "should allow to unproxy a user" do + proxied_user = @cf_client.unset_proxy_user() + proxied_user.should be_nil + @cf_client.proxy_user.should be_nil + end + + it "should not get user account information from target cloud" do + VCR.use_cassette("no_logged/users_unproxy_action", :record => :new_episodes, :exclusive => true) do + proxied_user = @cf_client.unset_proxy_user() + cloud_info = @cf_client.cloud_info() + cloud_info.should_not have_key :user + end + end + + it "should raise a BadParams exception when login with a blank email" do + expect { + @cf_client.login("", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when login with a blank password" do + expect { + @cf_client.login("user@vcap.me", "") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a Forbidden exception if login to the target cloud fails" do + expect { + @cf_client.login("user@vcap.me", "password") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should return false if user is not logged in at target cloud" do + @cf_client.logged_in?.should be_false + @cf_client.user.should be_nil + @cf_client.auth_token.should be_nil + end + + it "should allow to login correctly at target cloud and return an auth_token" do + VCR.use_cassette("no_logged/users_login_action", :record => :new_episodes, :exclusive => true) do + auth_token = @cf_client.login("user@vcap.me", "foobar") + @cf_client.user.should_not be_nil + @cf_client.user.should eql("user@vcap.me") + @cf_client.auth_token.should_not be_nil + @cf_client.auth_token.should eql(auth_token) + end + end + + it "should return true if user is logged in at target cloud" do + VCR.use_cassette("no_logged/users_login_action", :record => :new_episodes, :exclusive => true) do + @cf_client.logged_in?.should be_true + end + end + end + + context "with a user logged in" do + before(:all) do + VCR.use_cassette("user_logged/client", :record => :new_episodes) do + @cf_client = client_user_logged() + end + end + + use_vcr_cassette "user_logged/users", :record => :new_episodes + + it "should return true if a new user is created at target cloud" do + created = @cf_client.create_user("fakeuser2@vcap.me", "foobar") + created.should be_true + end + + it "should raise a Forbidden exception when listing all users at target cloud" do + expect { + users = @cf_client.list_users() + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should raise an Forbidden exception when retrieving not own user information from target cloud" do + expect { + user_info = @cf_client.user_info("fakeuser1@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should properly get basic user information from target cloud" do + user_info = @cf_client.user_info("user@vcap.me") + user_info.should have_key :email + end + + it "should raise a Forbidden exception when updating not own user at target cloud" do + expect { + updated = @cf_client.update_user("fakeuser1@vcap.me", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should return true if a user is updated at target cloud" do + updated = @cf_client.update_user("user@vcap.me", "foobar") + updated.should be_true + end + + it "should raise a Forbidden exception when deleting not now user at target cloud" do + expect { + deleted = @cf_client.delete_user("fakeuser1@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should raise a Forbidden exception when deleting a user at target cloud" do + expect { + deleted = @cf_client.delete_user("user@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should allow to proxy a user" do + proxied_user = @cf_client.set_proxy_user("fakeuser1@vcap.me") + proxied_user.should eql("fakeuser1@vcap.me") + proxied_user.should eql(@cf_client.proxy_user) + end + + it "should raise a Forbidden exception when retrieving proxy user account information from target cloud" do + VCR.use_cassette("user_logged/users_proxy_action", :record => :new_episodes, :exclusive => true) do + expect { + proxied_user = @cf_client.set_proxy_user("fakeuser1@vcap.me") + cloud_info = @cf_client.cloud_info() + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + end + + it "should allow to unproxy a user" do + proxied_user = @cf_client.unset_proxy_user() + proxied_user.should be_nil + @cf_client.proxy_user.should be_nil + end + + it "should properly get current user account information from target cloud" do + VCR.use_cassette("user_logged/users_unproxy_action", :record => :new_episodes, :exclusive => true) do + proxied_user = @cf_client.unset_proxy_user() + cloud_info = @cf_client.cloud_info() + cloud_info[:user].should eql(@user) + end + end + + it "should return true if user is logged in at target cloud" do + @cf_client.logged_in?.should be_true + @cf_client.user.should_not be_nil + @cf_client.user.should eql(@user) + @cf_client.auth_token.should_not be_nil + @cf_client.auth_token.should eql(@auth_token) + end + end + + context "with an admin user logged in" do + before(:all) do + VCR.use_cassette("admin_logged/client", :record => :new_episodes) do + @cf_client = client_admin_logged() + end + end + + use_vcr_cassette "admin_logged/users", :record => :new_episodes + + it "should raise a BadParams exception when creating a user with a blank email" do + expect { + created = @cf_client.create_user("", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when creating a user with a blank password" do + expect { + created = @cf_client.create_user("fakeuser@vcap.me", "") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadRequest exception when creating a user that already exists at target cloud" do + expect { + created = @cf_client.create_user("user@vcap.me", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::BadRequest) + end + + it "should return true if a new user is created at target cloud" do + VCR.use_cassette("admin_logged/users_create_action", :record => :new_episodes, :exclusive => true) do + created = @cf_client.create_user("fakeuser@vcap.me", "foobar") + created.should be_true + end + end + + it "should get a proper list of users at target cloud" do + users = @cf_client.list_users() + users.should have_at_least(1).items + user_info = users.first + user_info.should have_key :email + user_info.should have_key :admin + user_info.should have_key :apps + end + + it "should raise a BadParams exception when retrieving information about a user with a blank email" do + expect { + user_info = @cf_client.user_info("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a Forbidden exception when retrieving information about a user that does not exists at target cloud" do + expect { + user_info = @cf_client.user_info("nouser@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should properly get basic user information from target cloud" do + user_info = @cf_client.user_info("fakeuser@vcap.me") + user_info.should have_key :email + end + + it "should raise a BadParams exception when updating a user with a blank email" do + expect { + created = @cf_client.update_user("", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when updating a user with a blank password" do + expect { + created = @cf_client.update_user("fakeuser@vcap.me", "") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a Forbidden exception when updating a user that does not exists at target cloud" do + expect { + updated = @cf_client.update_user("nouser@vcap.me", "foobar") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should return true if a user is updated at target cloud" do + updated = @cf_client.update_user("fakeuser@vcap.me", "foobar") + updated.should be_true + end + + it "should raise a BadParams exception when deleting a user with a blank email" do + expect { + created = @cf_client.delete_user("") + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a Forbidden exception when deleting a user that does not exists at target cloud" do + expect { + deleted = @cf_client.delete_user("nouser@vcap.me") + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + + it "should return true if a user is deleted at target cloud" do + deleted = @cf_client.delete_user("fakeuser@vcap.me") + deleted.should be_true + end + + it "should return true if a user is deleted at target cloud" do + deleted = @cf_client.delete_user("fakeuser1@vcap.me") + deleted.should be_true + end + + it "should return true if a user is deleted at target cloud" do + deleted = @cf_client.delete_user("fakeuser2@vcap.me") + deleted.should be_true + end + + it "should allow to proxy a user" do + proxied_user = @cf_client.set_proxy_user("user@vcap.me") + proxied_user.should eql("user@vcap.me") + proxied_user.should eql(@cf_client.proxy_user) + end + + it "should properly get proxy user account information from target cloud" do + VCR.use_cassette("admin_logged/users_proxy_action", :record => :new_episodes, :exclusive => true) do + proxied_user = @cf_client.set_proxy_user("user@vcap.me") + cloud_info = @cf_client.cloud_info() + cloud_info[:user].should eql("user@vcap.me") + cloud_info[:user].should eql(@cf_client.proxy_user) + end + end + + it "should allow to proxy a user that does not exists at target cloud" do + proxied_user = @cf_client.set_proxy_user("nouser@vcap.me") + proxied_user.should eql("nouser@vcap.me") + proxied_user.should eql(@cf_client.proxy_user) + end + + it "should raise a Forbidden exception when retrieving proxy user account information that does not exists at target cloud" do + VCR.use_cassette("admin_logged/users_proxy_nouser_action", :record => :new_episodes, :exclusive => true) do + expect { + proxied_user = @cf_client.set_proxy_user("nouser@vcap.me") + cloud_info = @cf_client.cloud_info() + }.to raise_exception(CloudFoundry::Client::Exception::Forbidden) + end + end + + it "should allow to unproxy a user" do + proxied_user = @cf_client.unset_proxy_user() + proxied_user.should be_nil + @cf_client.proxy_user.should be_nil + end + + it "should properly get current user account information from target cloud" do + VCR.use_cassette("admin_logged/users_unproxy_action", :record => :new_episodes, :exclusive => true) do + proxied_user = @cf_client.unset_proxy_user() + cloud_info = @cf_client.cloud_info() + cloud_info[:user].should eql(@user) + end + end + + it "should return true if user is logged in at target cloud" do + @cf_client.logged_in?.should be_true + @cf_client.user.should_not be_nil + @cf_client.user.should eql(@user) + @cf_client.auth_token.should eql(@auth_token) + end + end +end \ No newline at end of file diff --git a/spec/client_spec.rb b/spec/client_spec.rb new file mode 100755 index 0000000..2962691 --- /dev/null +++ b/spec/client_spec.rb @@ -0,0 +1,110 @@ +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') + +describe "Cloudfoundry::Client" do + include CfConnectionHelper + + before(:all) do + client_data() + end + + use_vcr_cassette "client", :record => :new_episodes + + it "should report its version" do + CloudFoundry::Client::VERSION.should match(/\d.\d.\d/) + end + + it "should properly initialize when no options are passed" do + cf_client = CloudFoundry::Client.new() + cf_client.target_url.should eql(CloudFoundry::Client::DEFAULT_TARGET) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should be_nil + cf_client.auth_token.should be_nil + cf_client.user.should be_nil + cf_client.proxy_user.should be_nil + end + + it "should properly initialize with only proxy_url option" do + cf_client = CloudFoundry::Client.new({:proxy_url => "http://proxy.rodenas.org"}) + cf_client.target_url.should eql(CloudFoundry::Client::DEFAULT_TARGET) + cf_client.proxy_url.should eql("http://proxy.rodenas.org") + cf_client.trace_key.should be_nil + cf_client.auth_token.should be_nil + cf_client.user.should be_nil + cf_client.proxy_user.should be_nil + end + + it "should properly initialize with only target_url option" do + cf_client = CloudFoundry::Client.new({:target_url => @target}) + cf_client.target_url.should eql(@target) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should be_nil + cf_client.auth_token.should be_nil + cf_client.user.should be_nil + cf_client.proxy_user.should be_nil + end + + it "should normalize a target_url with no scheme" do + cf_client = CloudFoundry::Client.new({:target_url => "api.vcap.me"}) + cf_client.target_url.should eql("http://api.vcap.me") + end + + it "should not normalize a target_url with an http scheme" do + cf_client = CloudFoundry::Client.new({:target_url => "http://api.vcap.me"}) + cf_client.target_url.should eql("http://api.vcap.me") + end + + it "should not normalize a target_url with an https scheme" do + cf_client = CloudFoundry::Client.new({:target_url => "https://api.cloudfoundry.com"}) + cf_client.target_url.should eql("https://api.cloudfoundry.com") + end + + it "should properly initialize with only trace_key option" do + cf_client = CloudFoundry::Client.new({:trace_key => "22"}) + cf_client.target_url.should eql(CloudFoundry::Client::DEFAULT_TARGET) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should eql("22") + cf_client.auth_token.should be_nil + cf_client.user.should be_nil + cf_client.proxy_user.should be_nil + end + + it "should properly initialize with only auth_token option" do + cf_client = CloudFoundry::Client.new({:auth_token => @auth_token}) + cf_client.target_url.should eql(CloudFoundry::Client::DEFAULT_TARGET) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should be_nil + cf_client.auth_token.should eql(@auth_token) + cf_client.user.should eql(@user) + cf_client.proxy_user.should be_nil + end + + it "should properly initialize with target_url and auth_token options" do + cf_client = CloudFoundry::Client.new({:target_url => @target, :auth_token => @auth_token}) + cf_client.target_url.should eql(@target) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should be_nil + cf_client.auth_token.should eql(@auth_token) + cf_client.user.should eql(@user) + cf_client.proxy_user.should be_nil + end + + it "should raise a BadParams exception when target_url is an invalid URL" do + expect { + cf_client = CloudFoundry::Client.new({:target_url => "fakeaddress"}) + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise a BadParams exception when target_url is an invalid CloudFoundry target" do + expect { + cf_client = CloudFoundry::Client.new({:target_url => "http://www.example.com"}) + }.to raise_exception(CloudFoundry::Client::Exception::BadParams) + end + + it "should raise an AuthError exception when auth_token is invalid in the CloudFoundry target" do + VCR.use_cassette("client_invalid", :record => :new_episodes, :exclusive => true) do + expect { + cf_client = CloudFoundry::Client.new({:auth_token => "invalid_auth_token"}) + }.to raise_exception(CloudFoundry::Client::Exception::AuthError) + end + end +end diff --git a/spec/cloudfoundry_spec.rb b/spec/cloudfoundry_spec.rb new file mode 100755 index 0000000..3bb340e --- /dev/null +++ b/spec/cloudfoundry_spec.rb @@ -0,0 +1,62 @@ +require File.expand_path(File.dirname(__FILE__) + '/spec_helper') + +describe "Cloudfoundry" do + include CfConnectionHelper + + before(:all) do + client_data() + end + + use_vcr_cassette "cloudfoundry", :record => :new_episodes + + it "should report its version" do + CloudFoundry::VERSION.should match(/\d.\d.\d/) + CloudFoundry::VERSION.should eql(CloudFoundry::Client::VERSION) + end + + it "should properly initialize when no options are passed" do + cf_client = CloudFoundry.new() + cf_client.target_url.should eql(CloudFoundry::Client::DEFAULT_TARGET) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should be_nil + cf_client.auth_token.should be_nil + cf_client.user.should be_nil + cf_client.proxy_user.should be_nil + end + + it "should be a CloudFoundry::Client" do + cf_client = CloudFoundry.new() + cf_client.should be_a CloudFoundry::Client + end + + it "should properly initialize with target_url and auth_token options" do + cf_client = CloudFoundry.new({:target_url => @target, :auth_token => @auth_token}) + cf_client.target_url.should eql(@target) + cf_client.proxy_url.should be_nil + cf_client.trace_key.should be_nil + cf_client.auth_token.should eql(@auth_token) + cf_client.user.should eql(@user) + cf_client.proxy_user.should be_nil + end + + it "should delegate any method to CloudFoundry::Client" do + cf_client = CloudFoundry.new({:target_url => @target, :auth_token => @auth_token}) + cloud_info = cf_client.cloud_info() + cloud_info.should have_key :name + cloud_info.should have_key :build + cloud_info.should have_key :support + cloud_info.should have_key :version + cloud_info.should have_key :description + cloud_info.should have_key :allow_debug + end + + it "should return the same results as a CloudFoundry::Client" do + VCR.use_cassette("cloudfoundry_vs_client", :record => :new_episodes, :exclusive => true) do + cf_client_1 = CloudFoundry.new() + cloud_info_1 = cf_client_1.cloud_info() + cf_client_2 = CloudFoundry::Client.new() + cloud_info_2 = cf_client_2.cloud_info() + cloud_info_1.should eql(cloud_info_2) + end + end +end \ No newline at end of file diff --git a/spec/fixtures/admin_logged/client.yml b/spec/fixtures/admin_logged/client.yml new file mode 100644 index 0000000..5f6d3f8 --- /dev/null +++ b/spec/fixtures/admin_logged/client.yml @@ -0,0 +1,85 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"14474b6291887f823279b1168c3c5063\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"admin@vcap.me\",\"limits\":{\"memory\":32768,\"app_uris\":16,\"services\":32,\"apps\":200},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"14474b6291887f823279b1168c3c5063\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"admin@vcap.me\",\"limits\":{\"memory\":32768,\"app_uris\":16,\"services\":32,\"apps\":200},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/admin_logged/users.yml b/spec/fixtures/admin_logged/users.yml new file mode 100644 index 0000000..9ea2512 --- /dev/null +++ b/spec/fixtures/admin_logged/users.yml @@ -0,0 +1,363 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/users + body: "{\"email\":\"user@vcap.me\",\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 400 + message: Bad Request + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":100,\"description\":\"Bad request\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +- request: + method: get + uri: http://api.vcap.me:80/users + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"dbf9750f6f10ca8c34d7a42e0f3f16bf\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "[{\"email\":\"admin@vcap.me\",\"admin\":true,\"apps\":[]},{\"email\":\"user@vcap.me\",\"admin\":false,\"apps\":[{\"name\":\"newapp\",\"state\":\"STOPPED\"}]},{\"email\":\"fakeuser1@vcap.me\",\"admin\":false,\"apps\":[]},{\"email\":\"fakeuser2@vcap.me\",\"admin\":false,\"apps\":[]},{\"email\":\"fakeuser@vcap.me\",\"admin\":false,\"apps\":[]}]" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: get + uri: http://api.vcap.me:80/users/nouser@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":201,\"description\":\"User not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: get + uri: http://api.vcap.me:80/users/fakeuser@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"3dd4a78f201e918efd9b16af0f2d2dfd\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"email\":\"fakeuser@vcap.me\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: put + uri: http://api.vcap.me:80/users/fakeuser@vcap.me + body: "{\"email\":\"fakeuser@vcap.me\",\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: delete + uri: http://api.vcap.me:80/users/nouser@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - "*/*" + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":201,\"description\":\"User not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: delete + uri: http://api.vcap.me:80/users/fakeuser@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - "*/*" + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: delete + uri: http://api.vcap.me:80/users/fakeuser1@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - "*/*" + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:53 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +- request: + method: delete + uri: http://api.vcap.me:80/users/fakeuser2@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - "*/*" + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:53 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:52 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:53 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"14474b6291887f823279b1168c3c5063\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"admin@vcap.me\",\"limits\":{\"memory\":32768,\"app_uris\":16,\"services\":32,\"apps\":200},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:52 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/admin_logged/users_create_action.yml b/spec/fixtures/admin_logged/users_create_action.yml new file mode 100644 index 0000000..f404759 --- /dev/null +++ b/spec/fixtures/admin_logged/users_create_action.yml @@ -0,0 +1,36 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/users + body: "{\"email\":\"fakeuser@vcap.me\",\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:52 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:51 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/admin_logged/users_proxy_action.yml b/spec/fixtures/admin_logged/users_proxy_action.yml new file mode 100644 index 0000000..bf9c676 --- /dev/null +++ b/spec/fixtures/admin_logged/users_proxy_action.yml @@ -0,0 +1,46 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Proxy-User: + - user@vcap.me + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:53 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:52 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/admin_logged/users_proxy_nouser_action.yml b/spec/fixtures/admin_logged/users_proxy_nouser_action.yml new file mode 100644 index 0000000..1c5c462 --- /dev/null +++ b/spec/fixtures/admin_logged/users_proxy_nouser_action.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Proxy-User: + - nouser@vcap.me + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:53 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":201,\"description\":\"User not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:52 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/admin_logged/users_unproxy_action.yml b/spec/fixtures/admin_logged/users_unproxy_action.yml new file mode 100644 index 0000000..d105ef5 --- /dev/null +++ b/spec/fixtures/admin_logged/users_unproxy_action.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:53 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"14474b6291887f823279b1168c3c5063\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"admin@vcap.me\",\"limits\":{\"memory\":32768,\"app_uris\":16,\"services\":32,\"apps\":200},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:52 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/app.js b/spec/fixtures/app.js new file mode 100644 index 0000000..09ad914 --- /dev/null +++ b/spec/fixtures/app.js @@ -0,0 +1,16 @@ +var http = require('http'); +var url = require('url'); + +HOST = null; + +var host = process.env.VCAP_APP_HOST || 'localhost'; +var port = process.env.VCAP_APP_PORT || 3000 + +http.createServer(function (req, res) { + res.writeHead(200, {'Content-Type': 'text/html'}); + res.write('

Hello from the Cloud! '); + res.write('via: ' + host + ':' + port); + res.end('

'); +}).listen(port, null); + +console.log('Server running at http://' + host + ':' + port + '/'); \ No newline at end of file diff --git a/spec/fixtures/app.zip b/spec/fixtures/app.zip new file mode 100644 index 0000000000000000000000000000000000000000..84e2adb0f0781c0a9f21efe2761328b287facea2 GIT binary patch literal 441 zcmWIWW@Zs#U|`^2aGqIhZ#Dn!T5(1OhLb?d#vsFxSWuvsRU8_^$-w-t=8|8m_zl0( z3T_5QmajksV11>5r}LT(1onIuy*;_tsd1b6uL(+ecbaCcxXy7-8<6lj`5k z@(2ytYTjR-X0v&o6u0d~j`Im0@A8W+<%l@afANTM{?)G?i8EZTX6=1g{dQ`SNXOp7 zBj$@ub*-i^ns;e?QDpw~(!FzUE*IuVz2(NbY{!oNWB;^Qg|FZILh<}(4X&A&t|d9| zaI;=G)p~ujR1e$9mqL9nk}TW=_+GZla%ksRRnC9TDdU=HvT)h$v)4NoF*yG4jPz$$ zJs0!bOXX;A{r8}SL2PB$WE!ekf+X+XZTR6kx2i1f0|PJ!8J0AHSg>Gbg#rl0@- literal 0 HcmV?d00001 diff --git a/spec/fixtures/client.yml b/spec/fixtures/client.yml new file mode 100644 index 0000000..241c9ee --- /dev/null +++ b/spec/fixtures/client.yml @@ -0,0 +1,151 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:31 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:30 GMT +- request: + method: get + uri: https://api.cloudfoundry.com:443/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Fri, 02 Dec 2011 01:08:23 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"5431abc7cc6e51d695c5ff65743c11ed\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge,chrome=1 + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":false}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:32 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:33 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:32 GMT +- request: + method: get + uri: http://www.example.com:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 302 + message: Found + headers: + Location: + - http://www.iana.org/domains/example/ + Server: + - BigIP + Connection: + - Keep-Alive + Content-Length: + - "0" + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:32 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/client_invalid.yml b/spec/fixtures/client_invalid.yml new file mode 100644 index 0000000..7635826 --- /dev/null +++ b/spec/fixtures/client_invalid.yml @@ -0,0 +1,85 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - invalid_auth_token + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - invalid_auth_token + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/cloudfoundry.yml b/spec/fixtures/cloudfoundry.yml new file mode 100644 index 0000000..01ce577 --- /dev/null +++ b/spec/fixtures/cloudfoundry.yml @@ -0,0 +1,124 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/cloudfoundry_vs_client.yml b/spec/fixtures/cloudfoundry_vs_client.yml new file mode 100644 index 0000000..fd9a12a --- /dev/null +++ b/spec/fixtures/cloudfoundry_vs_client.yml @@ -0,0 +1,159 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/apps.yml b/spec/fixtures/no_logged/apps.yml new file mode 100644 index 0000000..dac75d5 --- /dev/null +++ b/spec/fixtures/no_logged/apps.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:35 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:34 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/client.yml b/spec/fixtures/no_logged/client.yml new file mode 100644 index 0000000..8457b46 --- /dev/null +++ b/spec/fixtures/no_logged/client.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:34 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:33 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/info.yml b/spec/fixtures/no_logged/info.yml new file mode 100644 index 0000000..c6384ff --- /dev/null +++ b/spec/fixtures/no_logged/info.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:42 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:41 GMT +- request: + method: get + uri: http://api.vcap.me:80/info/runtimes + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"2f385a3c5eaf836cbbd0ca37c1c5c5a7\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"ruby18\":{\"version\":\"1.8.7\"},\"ruby19\":{\"version\":\"1.9.2\"},\"node\":{\"version\":\"0.4.[2-9]\"},\"java\":{\"version\":\"1.6.0\",\"debug_modes\":[\"run\",\"suspend\"]},\"php\":{\"version\":\"5.3.[2-6]\"},\"erlangR14B02\":{\"version\":\".* 5.8.3\"},\"python26\":{\"version\":\"2.6.5\"}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:41 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/resources.yml b/spec/fixtures/no_logged/resources.yml new file mode 100644 index 0000000..d27ee97 --- /dev/null +++ b/spec/fixtures/no_logged/resources.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/services.yml b/spec/fixtures/no_logged/services.yml new file mode 100644 index 0000000..d27ee97 --- /dev/null +++ b/spec/fixtures/no_logged/services.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/users.yml b/spec/fixtures/no_logged/users.yml new file mode 100644 index 0000000..eeb8e53 --- /dev/null +++ b/spec/fixtures/no_logged/users.yml @@ -0,0 +1,108 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/users + body: "{\"email\":\"fakeuser1@vcap.me\",\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +- request: + method: post + uri: http://api.vcap.me:80/users/user@vcap.me/tokens + body: "{\"password\":\"password\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/users_login_action.yml b/spec/fixtures/no_logged/users_login_action.yml new file mode 100644 index 0000000..f1d81fe --- /dev/null +++ b/spec/fixtures/no_logged/users_login_action.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/users/user@vcap.me/tokens + body: "{\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"0537de394c2de40c0b698017f41bd786\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"token\":\"04085b084922117573657240766361702e6d65063a0645546c2b07de5fe14e221919a1d076f95d3f846f4a0ef36144dfc19ba6973e\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b07de5fe14e221919a1d076f95d3f846f4a0ef36144dfc19ba6973e + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/users_proxy_action.yml b/spec/fixtures/no_logged/users_proxy_action.yml new file mode 100644 index 0000000..75ff14b --- /dev/null +++ b/spec/fixtures/no_logged/users_proxy_action.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Proxy-User: + - user@vcap.me + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/no_logged/users_unproxy_action.yml b/spec/fixtures/no_logged/users_unproxy_action.yml new file mode 100644 index 0000000..c8b5a1f --- /dev/null +++ b/spec/fixtures/no_logged/users_unproxy_action.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cbc07ff8530919ca664fcfc8b21a398b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps.yml b/spec/fixtures/user_logged/apps.yml new file mode 100644 index 0000000..7f04bff --- /dev/null +++ b/spec/fixtures/user_logged/apps.yml @@ -0,0 +1,828 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/apps + body: "{\"name\":\"newapp\",\"instances\":1}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 400 + message: Bad Request + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:35 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":308,\"description\":\"Invalid framework description: 'NONE'\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:34 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"aa90afe7a7b4848b828be64a52510d08\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "[{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":null,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"4064f2adcae38ca6618493d61c77ca02-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":1,\"created\":1322788176}},{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":null,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"43063054166406f64a56f2d45b7bbd4f-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":1,\"created\":1322788176}}]" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:34 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"0add7cf429b9bdad147d9dfb6bb55e19\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"86e45ab956e1a0bbd648a9dda3bc3298-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":1,\"created\":1322788176}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp/instances + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/instances + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"1439580006f77fa0b8481cdc5a207b66\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"instances\":[]}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp/stats + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/stats + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"99914b932bd37a50b983c5e7c90ae93b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp/crashes + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/crashes + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"8f95df9c232fa5b8b530dcbe0687c0d0\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"crashes\":[]}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp/instances/0/files/ + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:36 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/instances/0/files/ + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 400 + message: Bad Request + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":305,\"description\":\"Operation not permitted on a stopped app\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:35 GMT +- request: + method: put + uri: http://api.vcap.me:80/apps/noapp + body: "{\"name\":\"noapp\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:36 GMT +- request: + method: put + uri: http://api.vcap.me:80/apps/newapp + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":2,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"86e45ab956e1a0bbd648a9dda3bc3298-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":1,\"created\":1322788176}}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:36 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp/update + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:36 GMT +- request: + method: put + uri: http://api.vcap.me:80/apps/noapp/application + body: !binary | + LS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50LURpc3Bv + c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImFwcGxpY2F0aW9uIjsgZmlsZW5h + bWU9ImFwcC56aXAiDQpDb250ZW50LUxlbmd0aDogNDQxDQpDb250ZW50LVR5 + cGU6IGFwcGxpY2F0aW9uL3ppcA0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGlu + ZzogYmluYXJ5DQoNClBLAwQUAAAACABDmXs/Op/drRcBAADJAQAABgAcAGFw + cC5qc1VUCQAD/nzSTl0X2E51eAsAAQT1AQAABBQAAAB1UctugzAQvPMV25ON + QoG2N/qQIi7cgpqo1wjBJiA5NrXXtFWSf++aSFVUtTePd2Y8s54aCz3RCM9g + 8d0PFqUIWMSP0cQzb9X1iGGYRNVqveF77ZViFIi9ccQ3ozUtOpeintK3cllv + l3W9ndmnEwhl2kYFpri4j8b+K6pXr7PoIc/zKAqZ0tZiQ7hGO6GVO69bGowG + yekSjuhiOEYQDumHHQgrbDp5n+cJHEVpNKGm283XiKIAQfhJWU8HJc5c50ok + xVN/91KhUgZ21hyAeoRSGd/dgPhNnYaGvWBxKb8AUQQQSv0wUXdsmbFnUJ/j + VA2Ok8hASub9hXW2RjujMFVmL8WlH1iv9aD30ND8QUWW/flSABl7fwNQSwEC + HgMUAAAACABDmXs/Op/drRcBAADJAQAABgAYAAAAAAABAAAApIEAAAAAYXBw + LmpzVVQFAAP+fNJOdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAABAAEATAAAAFcB + AAAAAA0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50 + LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InJlc291cmNlcyINCg0K + W10NCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC0tDQoNCg== + + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Content-Type: + - multipart/form-data;boundary=-----------RubyMultipartPost + Content-Length: + - "760" + Accept: + - "*/*" + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:36 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/noapp/application + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:36 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/application + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:37 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:36 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/instances/0/files/app/nofile + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 500 + message: Internal Server Error + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:40 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":306,\"description\":\"Error retrieving file 'app/nofile'\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:39 GMT +- request: + method: delete + uri: http://api.vcap.me:80/apps/noapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:42 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:41 GMT +- request: + method: delete + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:42 GMT + Content-Type: + - text/html; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Vary: + - Accept-Encoding + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:41 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_create_action.yml b/spec/fixtures/user_logged/apps_create_action.yml new file mode 100644 index 0000000..355ae92 --- /dev/null +++ b/spec/fixtures/user_logged/apps_create_action.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/apps + body: "{\"name\":\"newapp\",\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"staging\":{\"model\":\"node\"},\"resources\":{\"memory\":64}}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 302 + message: Moved Temporarily + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:35 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Location: + - http://api.vcap.me/apps/newapp + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"result\":\"success\",\"redirect\":\"http://api.vcap.me/apps/newapp\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:34 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_directory_action.yml b/spec/fixtures/user_logged/apps_directory_action.yml new file mode 100644 index 0000000..067d616 --- /dev/null +++ b/spec/fixtures/user_logged/apps_directory_action.yml @@ -0,0 +1,48 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/instances/0/files/app + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:40 GMT + Content-Type: + - text/html; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Vary: + - Accept-Encoding + Etag: + - "\"c36107859b246d0b71c8a3bc0f115956\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + Content-Encoding: + - gzip + body: !binary | + H4sIAAAAAAAAA0osKNDLKlYgApiYmjsBAAAA//8DAO6SkFUuAAAA + + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:38 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_download_action.yml b/spec/fixtures/user_logged/apps_download_action.yml new file mode 100644 index 0000000..3f3dd14 --- /dev/null +++ b/spec/fixtures/user_logged/apps_download_action.yml @@ -0,0 +1,55 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/application + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:40 GMT + Content-Type: + - application/octet-stream + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Content-Disposition: + - attachment; filename="46c0a630f12c9970996304e0d7e3848e8ea02342" + Content-Transfer-Encoding: + - binary + Cache-Control: + - private + X-Ua-Compatible: + - IE=Edge + body: !binary | + UEsDBBQAAAAIAEOZez86n92tFwEAAMkBAAAGABwAYXBwLmpzVVQJAAP+fNJO + UiXYTnV4CwABBOgDAAAE6AMAAHVRy26DMBC88xXbk41CgbY3+pAiLtyCmqjX + CMEmIDk2tde0VZJ/75pIVVS1N493ZjyznhoLPdEIz2Dx3Q8WpQhYxI/RxDNv + 1fWIYZhE1Wq94XvtlWIUiL1xxDejNS06l6Ke0rdyWW+Xdb2d2acTCGXaRgWm + uLiPxv4rqlevs+ghz/MoCpnS1mJDuEY7oZU7r1sajAbJ6RKO6GI4RhAO6Ycd + CCtsOnmf5wkcRWk0oabbzdeIogBB+ElZTwclzlznSiTFU3/3UqFSBnbWHIB6 + hFIZ392A+E2dhoa9YHEpvwBRBBBK/TBRd2yZsWdQn+NUDY6TyEBK5v2FdbZG + O6MwVWYvxaUfWK/1oPfQ0PxBRZb9+VIAGXt/A1BLAQIeAxQAAAAIAEOZez86 + n92tFwEAAMkBAAAGABgAAAAAAAEAAACkgQAAAABhcHAuanNVVAUAA/580k51 + eAsAAQToAwAABOgDAABQSwUGAAAAAAEAAQBMAAAAVwEAAAAA + + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:38 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_file_action.yml b/spec/fixtures/user_logged/apps_file_action.yml new file mode 100644 index 0000000..152f7ef --- /dev/null +++ b/spec/fixtures/user_logged/apps_file_action.yml @@ -0,0 +1,54 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/instances/0/files/app/app.js + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:40 GMT + Content-Type: + - text/html; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Vary: + - Accept-Encoding + Etag: + - "\"845747baf6ef4d324e4dc3a42f193e2f\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + Content-Encoding: + - gzip + body: !binary | + H4sIAAAAAAAAA3RRTW+DMAy98yu8U4LKgG039iFVXLgVrdWuFQK3IKUJSxy2 + qe1/n0OlqZO2W579/PyeMzUWeqIRnsHiux8sShGwiB+jiXvequsWw9CJqtV6 + w3XtlWIUiL1xxJXRmhadS1FP6Vu5rLfLut7O7NMJhDJtowJTXNRHY/8dqlev + 89BDnudRFDylrcWGcI12Qit3Xrc0GA2SjSfs3sVwjCA80g87EFbYdPI+zxM4 + itJoQk23m68RRQGC8JOyng5KnDnO1ZAUT/3dS4VKGdhZcwDqEUplfHcDIfkv + 6jQ0rAWLS/gFiCKAEOqHibpjyYw1w/Q5TtXg2IkMpGS+Xzhna7QzClNl9lJc + 8oH1Wg96Dw3NH1Rk2Z+beKHIWPsbAAD//wMAOp/drckBAAA= + + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:39 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_start_action.yml b/spec/fixtures/user_logged/apps_start_action.yml new file mode 100644 index 0000000..60f999f --- /dev/null +++ b/spec/fixtures/user_logged/apps_start_action.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:38 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"4cde525f3691c444fc9445a9a6bed657\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":2,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"46c0a630f12c9970996304e0d7e3848e8ea02342-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":2,\"created\":1322788178}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:37 GMT +- request: + method: put + uri: http://api.vcap.me:80/apps/newapp + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":2,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STARTED\",\"services\":[],\"version\":\"46c0a630f12c9970996304e0d7e3848e8ea02342-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":2,\"created\":1322788178}}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:39 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:38 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_stats_action.yml b/spec/fixtures/user_logged/apps_stats_action.yml new file mode 100644 index 0000000..5c5aa22 --- /dev/null +++ b/spec/fixtures/user_logged/apps_stats_action.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/stats + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:42 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"1eabca381765acd8f9740f504120221e\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"0\":{\"state\":\"RUNNING\",\"stats\":{\"name\":\"newapp\",\"host\":\"127.0.0.1\",\"port\":60041,\"uris\":[\"newapp.vcap.me\"],\"uptime\":0.552919023,\"mem_quota\":67108864,\"disk_quota\":2147483648,\"fds_quota\":256,\"cores\":4}},\"1\":{\"state\":\"DOWN\",\"since\":1322788182}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:41 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_update_info_action.yml b/spec/fixtures/user_logged/apps_update_info_action.yml new file mode 100644 index 0000000..eb52377 --- /dev/null +++ b/spec/fixtures/user_logged/apps_update_info_action.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp/update + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:39 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"15971c1b7ebfc4ad060859b12901a3d7\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"state\":\"UPDATING\",\"since\":1322788179}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:38 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_upload_filename_action.yml b/spec/fixtures/user_logged/apps_upload_filename_action.yml new file mode 100644 index 0000000..5c2a9ab --- /dev/null +++ b/spec/fixtures/user_logged/apps_upload_filename_action.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: put + uri: http://api.vcap.me:80/apps/newapp/application + body: !binary | + LS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50LURpc3Bv + c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImFwcGxpY2F0aW9uIjsgZmlsZW5h + bWU9ImFwcC56aXAiDQpDb250ZW50LUxlbmd0aDogNDQxDQpDb250ZW50LVR5 + cGU6IGFwcGxpY2F0aW9uL3ppcA0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGlu + ZzogYmluYXJ5DQoNClBLAwQUAAAACABDmXs/Op/drRcBAADJAQAABgAcAGFw + cC5qc1VUCQAD/nzSTl0X2E51eAsAAQT1AQAABBQAAAB1UctugzAQvPMV25ON + QoG2N/qQIi7cgpqo1wjBJiA5NrXXtFWSf++aSFVUtTePd2Y8s54aCz3RCM9g + 8d0PFqUIWMSP0cQzb9X1iGGYRNVqveF77ZViFIi9ccQ3ozUtOpeintK3cllv + l3W9ndmnEwhl2kYFpri4j8b+K6pXr7PoIc/zKAqZ0tZiQ7hGO6GVO69bGowG + yekSjuhiOEYQDumHHQgrbDp5n+cJHEVpNKGm283XiKIAQfhJWU8HJc5c50ok + xVN/91KhUgZ21hyAeoRSGd/dgPhNnYaGvWBxKb8AUQQQSv0wUXdsmbFnUJ/j + VA2Ok8hASub9hXW2RjujMFVmL8WlH1iv9aD30ND8QUWW/flSABl7fwNQSwEC + HgMUAAAACABDmXs/Op/drRcBAADJAQAABgAYAAAAAAABAAAApIEAAAAAYXBw + LmpzVVQFAAP+fNJOdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAABAAEATAAAAFcB + AAAAAA0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50 + LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InJlc291cmNlcyINCg0K + W10NCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC0tDQoNCg== + + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Content-Type: + - multipart/form-data;boundary=-----------RubyMultipartPost + Content-Length: + - "760" + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:38 GMT + Content-Type: + - text/html; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Vary: + - Accept-Encoding + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:37 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/apps_upload_zipfile_action.yml b/spec/fixtures/user_logged/apps_upload_zipfile_action.yml new file mode 100644 index 0000000..5c2a9ab --- /dev/null +++ b/spec/fixtures/user_logged/apps_upload_zipfile_action.yml @@ -0,0 +1,62 @@ +--- +http_interactions: +- request: + method: put + uri: http://api.vcap.me:80/apps/newapp/application + body: !binary | + LS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50LURpc3Bv + c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImFwcGxpY2F0aW9uIjsgZmlsZW5h + bWU9ImFwcC56aXAiDQpDb250ZW50LUxlbmd0aDogNDQxDQpDb250ZW50LVR5 + cGU6IGFwcGxpY2F0aW9uL3ppcA0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGlu + ZzogYmluYXJ5DQoNClBLAwQUAAAACABDmXs/Op/drRcBAADJAQAABgAcAGFw + cC5qc1VUCQAD/nzSTl0X2E51eAsAAQT1AQAABBQAAAB1UctugzAQvPMV25ON + QoG2N/qQIi7cgpqo1wjBJiA5NrXXtFWSf++aSFVUtTePd2Y8s54aCz3RCM9g + 8d0PFqUIWMSP0cQzb9X1iGGYRNVqveF77ZViFIi9ccQ3ozUtOpeintK3cllv + l3W9ndmnEwhl2kYFpri4j8b+K6pXr7PoIc/zKAqZ0tZiQ7hGO6GVO69bGowG + yekSjuhiOEYQDumHHQgrbDp5n+cJHEVpNKGm283XiKIAQfhJWU8HJc5c50ok + xVN/91KhUgZ21hyAeoRSGd/dgPhNnYaGvWBxKb8AUQQQSv0wUXdsmbFnUJ/j + VA2Ok8hASub9hXW2RjujMFVmL8WlH1iv9aD30ND8QUWW/flSABl7fwNQSwEC + HgMUAAAACABDmXs/Op/drRcBAADJAQAABgAYAAAAAAABAAAApIEAAAAAYXBw + LmpzVVQFAAP+fNJOdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAABAAEATAAAAFcB + AAAAAA0KLS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50 + LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InJlc291cmNlcyINCg0K + W10NCi0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdC0tDQoNCg== + + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Content-Type: + - multipart/form-data;boundary=-----------RubyMultipartPost + Content-Length: + - "760" + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:38 GMT + Content-Type: + - text/html; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Vary: + - Accept-Encoding + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:37 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/client.yml b/spec/fixtures/user_logged/client.yml new file mode 100644 index 0000000..eb8701e --- /dev/null +++ b/spec/fixtures/user_logged/client.yml @@ -0,0 +1,85 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:35 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:34 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:35 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:34 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/info.yml b/spec/fixtures/user_logged/info.yml new file mode 100644 index 0000000..3a9286f --- /dev/null +++ b/spec/fixtures/user_logged/info.yml @@ -0,0 +1,126 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +- request: + method: get + uri: http://api.vcap.me:80/info/runtimes + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"2f385a3c5eaf836cbbd0ca37c1c5c5a7\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"ruby18\":{\"version\":\"1.8.7\"},\"ruby19\":{\"version\":\"1.9.2\"},\"node\":{\"version\":\"0.4.[2-9]\"},\"java\":{\"version\":\"1.6.0\",\"debug_modes\":[\"run\",\"suspend\"]},\"php\":{\"version\":\"5.3.[2-6]\"},\"erlangR14B02\":{\"version\":\".* 5.8.3\"},\"python26\":{\"version\":\"2.6.5\"}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +- request: + method: get + uri: http://api.vcap.me:80/info/services + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"c53736fe07a3f48b7e0f08c13d0649bd\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"key-value\":{\"redis\":{\"2.2\":{\"id\":1,\"vendor\":\"redis\",\"version\":\"2.2\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"key-value\",\"description\":\"Redis key-value store service\"}},\"mongodb\":{\"1.8\":{\"id\":3,\"vendor\":\"mongodb\",\"version\":\"1.8\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"key-value\",\"description\":\"MongoDB NoSQL store\"}}},\"database\":{\"mysql\":{\"5.1\":{\"id\":2,\"vendor\":\"mysql\",\"version\":\"5.1\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"database\",\"description\":\"MySQL database service\"}}},\"generic\":{\"neo4j\":{\"1.4\":{\"id\":4,\"vendor\":\"neo4j\",\"version\":\"1.4\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"generic\",\"description\":\"Neo4j NOSQL store\"}}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/resources.yml b/spec/fixtures/user_logged/resources.yml new file mode 100644 index 0000000..371e525 --- /dev/null +++ b/spec/fixtures/user_logged/resources.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/resources + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Content-Length: + - "0" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"d751713988987e9331980363e24189ce\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "[]" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/resources_check_action.yml b/spec/fixtures/user_logged/resources_check_action.yml new file mode 100644 index 0000000..45aa5ed --- /dev/null +++ b/spec/fixtures/user_logged/resources_check_action.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/resources + body: "[{\"size\":457,\"sha1\":\"80e11ec5ac403c9198776471c80aef8d84334ccb\",\"fn\":\"/Users/frodenas/Rails/cloudfoundry-client/spec/fixtures/app.js\"}]" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"5248cbc951edd3e9f89b389b66139630\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "[{\"size\":457,\"sha1\":\"80e11ec5ac403c9198776471c80aef8d84334ccb\",\"fn\":\"/Users/frodenas/Rails/cloudfoundry-client/spec/fixtures/app.js\"}]" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/services.yml b/spec/fixtures/user_logged/services.yml new file mode 100644 index 0000000..66137da --- /dev/null +++ b/spec/fixtures/user_logged/services.yml @@ -0,0 +1,354 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info/services + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"c53736fe07a3f48b7e0f08c13d0649bd\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"key-value\":{\"redis\":{\"2.2\":{\"id\":1,\"vendor\":\"redis\",\"version\":\"2.2\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"key-value\",\"description\":\"Redis key-value store service\"}},\"mongodb\":{\"1.8\":{\"id\":3,\"vendor\":\"mongodb\",\"version\":\"1.8\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"key-value\",\"description\":\"MongoDB NoSQL store\"}}},\"database\":{\"mysql\":{\"5.1\":{\"id\":2,\"vendor\":\"mysql\",\"version\":\"5.1\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"database\",\"description\":\"MySQL database service\"}}},\"generic\":{\"neo4j\":{\"1.4\":{\"id\":4,\"vendor\":\"neo4j\",\"version\":\"1.4\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"generic\",\"description\":\"Neo4j NOSQL store\"}}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +- request: + method: post + uri: http://api.vcap.me:80/services + body: "{\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"name\":\"redis-mock\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 400 + message: Bad Request + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:46 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"description\":\"Validation failed: Alias has already been taken\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:45 GMT +- request: + method: get + uri: http://api.vcap.me:80/services + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:46 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"81a77363e3c9ee36bcc903c128f173a7\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "[{\"name\":\"redis-mock\",\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"properties\":{},\"meta\":{\"created\":1322788185,\"updated\":1322788185,\"tags\":[\"redis\",\"redis-2.2\",\"key-value\",\"nosql\"],\"version\":1}}]" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:45 GMT +- request: + method: get + uri: http://api.vcap.me:80/services/noservice + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:46 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":500,\"description\":\"Service not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:45 GMT +- request: + method: get + uri: http://api.vcap.me:80/services/redis-mock + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:46 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"4d597daf1e538043afab00e953920f32\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"redis-mock\",\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"properties\":{},\"meta\":{\"created\":1322788185,\"updated\":1322788185,\"tags\":[\"redis\",\"redis-2.2\",\"key-value\",\"nosql\"],\"version\":1}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:45 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/appname + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:46 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":301,\"description\":\"Application not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:45 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"e102e2b9f13097abf0b76d9142798506\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[\"redis-mock\"],\"version\":\"538bc8f284a499ef33931b950abed7c4-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":2,\"created\":1322788188}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:46 GMT +- request: + method: delete + uri: http://api.vcap.me:80/services/noservice + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 404 + message: Not Found + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":500,\"description\":\"Service not found\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +- request: + method: delete + uri: http://api.vcap.me:80/services/redis-mock + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"99914b932bd37a50b983c5e7c90ae93b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:48 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/services_bind_action.yml b/spec/fixtures/user_logged/services_bind_action.yml new file mode 100644 index 0000000..de2238c --- /dev/null +++ b/spec/fixtures/user_logged/services_bind_action.yml @@ -0,0 +1,161 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/apps + body: "{\"name\":\"newapp\",\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"staging\":{\"model\":\"node\"},\"resources\":{\"memory\":64}}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 302 + message: Moved Temporarily + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:47 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Location: + - http://api.vcap.me/apps/newapp + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"result\":\"success\",\"redirect\":\"http://api.vcap.me/apps/newapp\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:46 GMT +- request: + method: get + uri: http://api.vcap.me:80/services/redis-mock + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:47 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"4d597daf1e538043afab00e953920f32\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"redis-mock\",\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"properties\":{},\"meta\":{\"created\":1322788185,\"updated\":1322788185,\"tags\":[\"redis\",\"redis-2.2\",\"key-value\",\"nosql\"],\"version\":1}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:46 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:47 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"167675c961893e367f1735839bd88b34\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"76c047be2a7bf6516de48594a05d4564-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":1,\"created\":1322788187}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:46 GMT +- request: + method: put + uri: http://api.vcap.me:80/apps/newapp + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[\"redis-mock\"],\"version\":\"76c047be2a7bf6516de48594a05d4564-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":1,\"created\":1322788187}}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:47 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:46 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/services_create_action.yml b/spec/fixtures/user_logged/services_create_action.yml new file mode 100644 index 0000000..a8b3ee4 --- /dev/null +++ b/spec/fixtures/user_logged/services_create_action.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info/services + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:43 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"c53736fe07a3f48b7e0f08c13d0649bd\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"key-value\":{\"redis\":{\"2.2\":{\"id\":1,\"vendor\":\"redis\",\"version\":\"2.2\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"key-value\",\"description\":\"Redis key-value store service\"}},\"mongodb\":{\"1.8\":{\"id\":3,\"vendor\":\"mongodb\",\"version\":\"1.8\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"key-value\",\"description\":\"MongoDB NoSQL store\"}}},\"database\":{\"mysql\":{\"5.1\":{\"id\":2,\"vendor\":\"mysql\",\"version\":\"5.1\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"database\",\"description\":\"MySQL database service\"}}},\"generic\":{\"neo4j\":{\"1.4\":{\"id\":4,\"vendor\":\"neo4j\",\"version\":\"1.4\",\"tiers\":{\"free\":{\"options\":{},\"order\":1}},\"type\":\"generic\",\"description\":\"Neo4j NOSQL store\"}}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:42 GMT +- request: + method: post + uri: http://api.vcap.me:80/services + body: "{\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"name\":\"redis-mock\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:45 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"99914b932bd37a50b983c5e7c90ae93b\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:44 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/services_unbind_action.yml b/spec/fixtures/user_logged/services_unbind_action.yml new file mode 100644 index 0000000..4ae9e32 --- /dev/null +++ b/spec/fixtures/user_logged/services_unbind_action.yml @@ -0,0 +1,122 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/services/redis-mock + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"4d597daf1e538043afab00e953920f32\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"redis-mock\",\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"properties\":{},\"meta\":{\"created\":1322788185,\"updated\":1322788185,\"tags\":[\"redis\",\"redis-2.2\",\"key-value\",\"nosql\"],\"version\":1}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:47 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"8571b411e6866e556264b30e33a16994\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[\"redis-mock\"],\"version\":\"f448ec65bfaed4f0cb7bf8c2623b73b4-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":2,\"created\":1322788188}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:47 GMT +- request: + method: put + uri: http://api.vcap.me:80/apps/newapp + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"f448ec65bfaed4f0cb7bf8c2623b73b4-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":2,\"created\":1322788188}}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:47 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/services_unbind_fail_action.yml b/spec/fixtures/user_logged/services_unbind_fail_action.yml new file mode 100644 index 0000000..b4c8b9d --- /dev/null +++ b/spec/fixtures/user_logged/services_unbind_fail_action.yml @@ -0,0 +1,122 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/services/redis-mock + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"4d597daf1e538043afab00e953920f32\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"redis-mock\",\"type\":\"key-value\",\"vendor\":\"redis\",\"version\":\"2.2\",\"tier\":\"free\",\"properties\":{},\"meta\":{\"created\":1322788185,\"updated\":1322788185,\"tags\":[\"redis\",\"redis-2.2\",\"key-value\",\"nosql\"],\"version\":1}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:47 GMT +- request: + method: get + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:48 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"cee25f0fe0c2c771ad852cc127dcc464\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"newapp\",\"staging\":{\"model\":\"node\",\"stack\":\"node\"},\"uris\":[\"newapp.vcap.me\"],\"instances\":1,\"runningInstances\":0,\"resources\":{\"memory\":64,\"disk\":2048,\"fds\":256},\"state\":\"STOPPED\",\"services\":[],\"version\":\"f845877c6de6d6ba7404ae76b43d7d52-0\",\"env\":[],\"meta\":{\"debug\":null,\"version\":3,\"created\":1322788188}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:47 GMT +- request: + method: delete + uri: http://api.vcap.me:80/apps/newapp + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:49 GMT + Content-Type: + - text/html; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Vary: + - Accept-Encoding + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: " " + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:47 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/users.yml b/spec/fixtures/user_logged/users.yml new file mode 100644 index 0000000..257b4ea --- /dev/null +++ b/spec/fixtures/user_logged/users.yml @@ -0,0 +1,299 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.vcap.me:80/users + body: "{\"email\":\"fakeuser2@vcap.me\",\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +- request: + method: get + uri: http://api.vcap.me:80/users + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +- request: + method: get + uri: http://api.vcap.me:80/users/fakeuser1@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +- request: + method: get + uri: http://api.vcap.me:80/users/user@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:50 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"44fcb5134ebc72bf6edcfd4d2fca9f93\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"email\":\"user@vcap.me\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +- request: + method: put + uri: http://api.vcap.me:80/users/user@vcap.me + body: "{\"email\":\"user@vcap.me\",\"password\":\"foobar\"}" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + response: + status: + code: 204 + message: No Content + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:49 GMT +- request: + method: delete + uri: http://api.vcap.me:80/users/fakeuser1@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +- request: + method: delete + uri: http://api.vcap.me:80/users/user@vcap.me + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - "*/*" + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/users_proxy_action.yml b/spec/fixtures/user_logged/users_proxy_action.yml new file mode 100644 index 0000000..e95af22 --- /dev/null +++ b/spec/fixtures/user_logged/users_proxy_action.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Proxy-User: + - fakeuser1@vcap.me + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 403 + message: Forbidden + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Cache-Control: + - no-cache + X-Ua-Compatible: + - IE=Edge + body: "{\"code\":200,\"description\":\"Operation not permitted\"}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/fixtures/user_logged/users_unproxy_action.yml b/spec/fixtures/user_logged/users_unproxy_action.yml new file mode 100644 index 0000000..6021823 --- /dev/null +++ b/spec/fixtures/user_logged/users_unproxy_action.yml @@ -0,0 +1,44 @@ +--- +http_interactions: +- request: + method: get + uri: http://api.vcap.me:80/info + body: "" + headers: + User-Agent: + - cloudfoundry-client-0.1.0 + Authorization: + - 04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f + Accept: + - application/json + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx/0.7.65 + Date: + - Fri, 02 Dec 2011 01:09:51 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=20 + Etag: + - "\"adea3e8a7bd68a058b88fbec459e2022\"" + Cache-Control: + - max-age=0, private, must-revalidate + X-Ua-Compatible: + - IE=Edge + body: "{\"name\":\"vcap\",\"build\":2222,\"support\":\"http://support.cloudfoundry.com\",\"version\":\"0.999\",\"description\":\"VMware's Cloud Application Platform\",\"allow_debug\":true,\"user\":\"user@vcap.me\",\"limits\":{\"memory\":2048,\"app_uris\":4,\"services\":16,\"apps\":20},\"usage\":{\"memory\":0,\"apps\":0,\"services\":0},\"frameworks\":{\"grails\":{\"name\":\"grails\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"spring\":{\"name\":\"spring\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"sinatra\":{\"name\":\"sinatra\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"*.rb\":\"require 'sinatra'|require \\\"sinatra\\\"\"},{\"config/environment.rb\":false}]},\"java_web\":{\"name\":\"java_web\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"php\":{\"name\":\"php\",\"runtimes\":[{\"name\":\"php\",\"version\":\"5.3\",\"description\":\"PHP 5\"}],\"appservers\":[{\"name\":\"apache\",\"description\":\"Apache\"}],\"detection\":[{\"*.php\":true}]},\"otp_rebar\":{\"name\":\"otp_rebar\",\"runtimes\":[{\"name\":\"erlangR14B02\",\"version\":\"R14B02\",\"description\":\"Erlang R14B02\"}],\"appservers\":[],\"detection\":[{\"releases/*/*.rel\":\".\"}]},\"lift\":{\"name\":\"lift\",\"runtimes\":[{\"name\":\"java\",\"version\":\"1.6\",\"description\":\"Java 6\"}],\"appservers\":[{\"name\":\"tomcat\",\"description\":\"Tomcat\"}],\"detection\":[{\"*.war\":true}]},\"rails3\":{\"name\":\"rails3\",\"runtimes\":[{\"name\":\"ruby18\",\"version\":\"1.8.7\",\"description\":\"Ruby 1.8.7\"},{\"name\":\"ruby19\",\"version\":\"1.9.2p180\",\"description\":\"Ruby 1.9.2\"}],\"appservers\":[{\"name\":\"thin\",\"description\":\"Thin\"}],\"detection\":[{\"config/application.rb\":true},{\"config/environment.rb\":true}]},\"django\":{\"name\":\"django\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]},\"node\":{\"name\":\"node\",\"runtimes\":[{\"name\":\"node\",\"version\":\"0.4.5\",\"description\":\"Node.js\"}],\"appservers\":[],\"detection\":[{\"*.js\":\".\"}]},\"wsgi\":{\"name\":\"wsgi\",\"runtimes\":[{\"name\":\"python26\",\"version\":\"2.6.5\",\"description\":\"Python 2.6.5\"}],\"appservers\":[],\"detection\":[{\"*.py\":\".\"}]}}}" + http_version: + recorded_at: Fri, 02 Dec 2011 01:09:50 GMT +recorded_with: VCR 2.0.0.beta2 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100755 index 0000000..bc683d0 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,29 @@ +begin + require 'simplecov' +rescue LoadError + # ignore +else + SimpleCov.start do + coverage_dir "doc/coverage" + add_group "CloudFoundry Client", "lib/cloudfoundry" + add_group "Specs", "spec" + end +end + +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +$LOAD_PATH.unshift(File.dirname(__FILE__)) +require 'rspec' +require 'rspec/autorun' +require 'webmock/rspec' +require 'cloudfoundry' + +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} + +RSpec.configure do |config| + # Make use_vcr_cassette available as a macro + config.extend VCR::RSpec::Macros +end + +def spec_fixture(filename) + File.expand_path(File.join(File.dirname(__FILE__), "fixtures", filename)) +end diff --git a/spec/support/cf_connection_helper.rb b/spec/support/cf_connection_helper.rb new file mode 100755 index 0000000..67d1033 --- /dev/null +++ b/spec/support/cf_connection_helper.rb @@ -0,0 +1,26 @@ +module CfConnectionHelper + def client_data() + @target = CloudFoundry::Client::DEFAULT_TARGET + @user = "user@vcap.me" + @password = "foobar" + @auth_token = "04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f" + end + + def client_no_logged() + @user = nil + @auth_token = nil + cf_client = CloudFoundry::Client.new() + end + + def client_user_logged() + @user = "user@vcap.me" + @auth_token = "04085b084922117573657240766361702e6d65063a0645546c2b073101dc4e2219f848b1aea2d82a2a6981750fa1aac61104aed60f" + cf_client = CloudFoundry::Client.new({:auth_token => @auth_token}) + end + + def client_admin_logged() + @user = "admin@vcap.me" + @auth_token = "04085b0849221261646d696e40766361702e6d65063a0645546c2b070101dc4e22196ec60283e0258107d4a7d98f66644938607fb049" + cf_client = CloudFoundry::Client.new({:auth_token => @auth_token}) + end +end \ No newline at end of file diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb new file mode 100755 index 0000000..20b08e5 --- /dev/null +++ b/spec/support/vcr.rb @@ -0,0 +1,8 @@ +require 'vcr' + +VCR.configure do |c| + c.cassette_library_dir = "spec/fixtures" + c.hook_into :webmock + c.default_cassette_options = {:record => :none} + c.allow_http_connections_when_no_cassette = false +end \ No newline at end of file