Add test code

Add code that can be used to test rather or not
we can retrieve our admins token.
This commit is contained in:
Dan Bode 2012-03-29 14:41:57 -07:00
parent b4bf55f2bf
commit a22cb5d689
1 changed files with 29 additions and 0 deletions

29
ext/keystone_test.rb Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# this script verifies that keystone has
# been successfully installed using the instructions
# found here: http://keystone.openstack.org/configuration.html
require 'open3'
require 'fileutils'
require 'puppet'
get_token = %(curl -d '{"auth":{"passwordCredentials":{"username": "admin", "password": "ChangeMe"}}}' -H "Content-type: application/json" http://localhost:35357/v2.0/tokens)
token = nil
Open3.popen3(get_token) do |stdin, stdout, stderr|
begin
stdout = stdout.read
puts "Response from token request:#{stdout}"
token = PSON.load(stdout)["access"]["token"]["id"]
rescue Exception => e
puts "Could not retrieve token from response, this sh*t is borked :( : details: #{e}"
exit 1
end
end
if token
puts "We were able to retrieve a token"
end