test/api_key_test.rb in fastly-1.1.4 vs test/api_key_test.rb in fastly-1.1.5
- old
+ new
@@ -1,46 +1,27 @@
require 'helper'
-class ApiKeyTest < Fastly::TestCase
- include CommonTests
+# API Key Tests
+class Fastly
+ describe 'ApiKeyTest' do
+ let(:opts) { login_opts(:api_key) }
+ let(:client) { Client.new(opts) }
+ let(:fastly) { Fastly.new(opts) }
- def setup
- @opts = login_opts(:api_key)
- begin
- @client = Fastly::Client.new(@opts)
- @fastly = Fastly.new(@opts)
- rescue Exception => e
- pp e
- exit(-1)
- end
- end
+ describe '#current_{user,customer}' do
+ it 'should not have access to current user 'do
+ assert_raises(Error) do
+ client.get('/current_user')
+ end
- def test_raw_client
- user = customer = nil
- assert_raise(Fastly::Error) {
- user = @client.get('/current_user')
- }
- assert_equal nil, user
+ assert_raises(FullAuthRequired) do
+ fastly.current_user
+ end
+ end
- customer = @client.get('/current_customer')
- assert customer
- assert_equal @opts[:customer], customer['name']
- end
-
- def test_current_user_and_customer
- current_user = current_customer = nil
- assert_raise(Fastly::FullAuthRequired) {
- current_user = @fastly.current_user
- }
- assert_equal nil, current_user
-
- customer = @fastly.current_customer
- assert customer
- assert_equal @opts[:customer], customer.name
- end
-
- def test_purging
- #assert @fastly.purge('foo')
- # TODO Won't work until we get fixtures in Heavenly
- #assert @fastly.purge_all('foo')
+ it 'should have access to current customer' do
+ assert_instance_of Hash, client.get('/current_customer')
+ assert_instance_of Customer, fastly.current_customer
+ end
+ end
end
end