forked from openshift/rhc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a887e9c
commit 9ed27fc
Showing
95 changed files
with
2,284 additions
and
663 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
require 'spec_helper' | ||
require 'direct_execution_helper' | ||
|
||
describe "rhc core scenarios" do | ||
|
||
it "reports a version" do | ||
r = rhc '--version' | ||
r.status.should == 0 | ||
r.stdout.should match /rhc \d+\.\d+\.\d+\b/ | ||
end | ||
|
||
it "displays help" do | ||
r = rhc 'help' | ||
r.status.should == 0 | ||
r.stdout.should match "Command line interface for OpenShift" | ||
r.stdout.should match "Usage: rhc" | ||
r.stdout.should match "Getting started" | ||
r.stdout.should match "See 'rhc help options' for a list" | ||
end | ||
|
||
context "with a clean configuration" do | ||
before{ use_clean_config } | ||
|
||
it "walks through a configuration" do | ||
r = rhc :setup, :with => setup_args | ||
r.stdout.should match 'OpenShift Client Tools' | ||
r.stdout.should match 'Checking for git ...' | ||
r.stdout.should match 'Checking for applications ...' | ||
r.stdout.should match 'Your client tools are now configured.' | ||
r.status.should == 0 | ||
|
||
r = rhc :account | ||
r.stdout.should match "on #{ENV['RHC_SERVER']}" | ||
r.stdout.should match 'Gears' | ||
r.stdout.should match 'Plan' | ||
end | ||
|
||
it "starts the wizard on default invocation" do | ||
r = rhc | ||
r.stdout.should match "OpenShift Client Tools" | ||
end | ||
end | ||
|
||
context "when creating an app" do | ||
when_running 'create-app', 'test1', a_web_cartridge | ||
before{ no_applications(/^test1/) } | ||
it "returns the proper info and is in the rest api" do | ||
status.should == 0 | ||
output.should match "Your application 'test1' is now available" | ||
output.should match /Gear Size: .*default/ | ||
output.should match /Scaling: .*no/ | ||
output.should match %r(URL: .*http://test1-) | ||
output.should match "Cloned to" | ||
|
||
apps = client.applications | ||
apps.should_not be_empty | ||
apps.should include{ |app| app.name == 'test1' } | ||
end | ||
end | ||
|
||
context "with an existing app" do | ||
before(:all) do | ||
standard_config | ||
@app = has_an_application | ||
end | ||
|
||
let(:app){ @app } | ||
|
||
it "should show app state" do | ||
r = rhc 'app-show', app.name, '--state' | ||
r.status.should == 0 | ||
r.stdout.should match "Cartridge #{a_web_cartridge} is started" | ||
end | ||
|
||
it "should stop and start the app" do | ||
r = rhc 'stop-app', app.name | ||
r.status.should == 0 | ||
r.stdout.should match "#{app.name} stopped" | ||
r = rhc 'start-app', app.name | ||
r.status.should == 0 | ||
r.stdout.should match "#{app.name} started" | ||
end | ||
|
||
it "should show gear status" do | ||
r = rhc 'app-show', app.name, '--gears' | ||
r.status.should == 0 | ||
r.stdout.lines.to_a.length.should == 3 | ||
r.stdout.should match app.ssh_string | ||
app.cartridges.map(&:name).each do |c| | ||
r.stdout.should match c | ||
end | ||
r.stdout.should match "started" | ||
end | ||
|
||
it "should show gear ssh strings" do | ||
r = rhc 'app-show', app.name, '--gears', 'ssh' | ||
r.status.should == 0 | ||
r.stdout.lines.to_a.length.should == 1 | ||
r.stdout.chomp.should == app.ssh_string | ||
end | ||
|
||
context "when the app is cloned" do | ||
before(:all) do | ||
rhc('git-clone', @app.name).status.should == 0 | ||
Dir.exists?(@app.name).should be_true | ||
Dir.chdir @app.name | ||
end | ||
let(:git_config){ `git config --list` } | ||
|
||
it "will set Git config values" do | ||
git_config.should match "rhc.app-id=#{app.id}" | ||
git_config.should match "rhc.app-name=#{app.name}" | ||
git_config.should match "rhc.domain-name=#{app.domain_name}" | ||
end | ||
|
||
it "will infer the current app from the git repository" do | ||
r = rhc 'show-app' | ||
r.stdout.should match app.name | ||
r.stdout.should match app.uuid | ||
r.stdout.should match app.ssh_string | ||
r.stdout.should match app.app_url | ||
(app.cartridges.map(&:name) + app.cartridges.map(&:display_name)).each{ |n| r.stdout.should match n } | ||
r.status.should == 0 | ||
end | ||
|
||
it "will fetch the quotas from the app" do | ||
r = rhc 'show-app', '--gears', 'quota' | ||
r.stdout.chomp.lines.count.should == (app.gear_count + 2) | ||
app.cartridges.map(&:name).each{ |n| r.stdout.should match n } | ||
app.cartridges.map(&:gear_storage).each{ |n| r.stdout.should match(RHC::Helpers.human_size(n)) } | ||
r.status.should == 0 | ||
end | ||
|
||
it "will ssh to the app and run a command" do | ||
r = rhc 'ssh', '--ssh', ENV['GIT_SSH'], 'echo $OPENSHIFT_APP_NAME' | ||
r.stdout.should match app.name | ||
r.status.should == 0 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'spec_helper' | ||
require 'direct_execution_helper' | ||
|
||
describe "rhc domain scenarios" do | ||
context "with an existing domain" do | ||
before(:all) do | ||
standard_config | ||
@domain = has_a_domain | ||
end | ||
let(:domain){ @domain } | ||
|
||
it "should display the domain configuration" do | ||
r = rhc 'configure-domain', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Allowed Gear Sizes:\s+#{domain.allowed_gear_sizes.join(", ")}" | ||
end | ||
|
||
it "should change the domain configuration" do | ||
r = rhc 'configure-domain', domain.id, '--no-allowed-gear-sizes' | ||
r.status.should == 0 | ||
r.stdout.should match "Allowed Gear Sizes:\s+<none>$" | ||
client.reset.find_domain(domain.id).allowed_gear_sizes.should == [] | ||
|
||
all_sizes = client.user.capabilities.gear_sizes | ||
r = rhc 'configure-domain', domain.id, '--allowed-gear-sizes', all_sizes.join(',') | ||
r.status.should == 0 | ||
r.stdout.should match "Allowed Gear Sizes:\s+#{all_sizes.join(', ')}$" | ||
client.reset.find_domain(domain.id).allowed_gear_sizes.should == all_sizes | ||
end | ||
|
||
it "should reject invalid gear size configuration changes" do | ||
all_sizes = client.user.capabilities.gear_sizes | ||
|
||
r = rhc 'configure-domain', domain.id, '--allowed-gear-sizes', '_not_a_size_' | ||
r.status.should_not == 1 | ||
r.stdout.should match "Updating domain configuration.*The following gear sizes are invalid: _not_a_size_" | ||
client.reset.find_domain(domain.id).allowed_gear_sizes.should == all_sizes | ||
|
||
r = rhc 'configure-domain', domain.id, '--allowed-gear-sizes' | ||
r.status.should_not == 1 | ||
r.stdout.should match "invalid option: Provide a comma delimited .* --allowed-gear-sizes" | ||
client.reset.find_domain(domain.id).allowed_gear_sizes.should == all_sizes | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
require 'spec_helper' | ||
require 'direct_execution_helper' | ||
|
||
describe "rhc member scenarios" do | ||
context "with an existing domain" do | ||
before(:all) do | ||
standard_config | ||
@domain = has_a_domain | ||
end | ||
|
||
let(:domain){ @domain } | ||
|
||
context "with no users" do | ||
before{ no_members(domain) } | ||
|
||
it "should not show members in the domain" do | ||
r = rhc 'show-domain', domain.id | ||
r.status.should == 0 | ||
r.stdout.should_not match "Members:" | ||
r.stdout.should match "owned by #{domain.owner}" | ||
end | ||
|
||
it "should prevent leaving the domain for the owner" do | ||
r = rhc 'leave-domain', domain.id | ||
r.status.should_not == 1 | ||
r.stdout.should match "Leaving domain.*You are the owner of this domain and cannot leave" | ||
end | ||
|
||
it "should add and remove a member" do | ||
user = other_users.keys.take(1).first | ||
r = rhc 'add-member', user, '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Adding 1 editor to domain" | ||
r.stdout.should match "done" | ||
client.find_domain(domain.id).members.any?{ |m| m.id == other_users[user].id && m.editor? }.should be_true | ||
|
||
r = rhc 'show-domain', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Members:" | ||
r.stdout.should match "#{user} \\(edit\\)" | ||
|
||
r = rhc 'remove-member', user, '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Removing 1 member from domain" | ||
client.find_domain(domain.id).members.none?{ |m| m.id == other_users[user].id }.should be_true | ||
end | ||
|
||
it "should add and remove two members" do | ||
user1, user2 = other_users.keys.take(2) | ||
r = rhc 'add-member', user1, user2, '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Adding 2 editors to domain" | ||
r.stdout.should match "done" | ||
members = client.find_domain(domain.id).members | ||
members.any?{ |m| m.id == other_users[user1].id && m.editor? }.should be_true | ||
members.any?{ |m| m.id == other_users[user2].id && m.editor? }.should be_true | ||
|
||
r = rhc 'show-domain', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Members:" | ||
r.stdout.should match "#{user1} \\(edit\\)" | ||
r.stdout.should match "#{user2} \\(edit\\)" | ||
|
||
r = rhc 'remove-member', user1, user2, '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Removing 2 members from domain" | ||
client.find_domain(domain.id).members.none?{ |m| m.id == other_users[user1].id }.should be_true | ||
client.find_domain(domain.id).members.none?{ |m| m.id == other_users[user2].id }.should be_true | ||
end | ||
|
||
it "should add a view and an admin member. and allow users to leave the domain" do | ||
user1, user2 = other_users.keys.take(2) | ||
|
||
r = rhc 'add-member', user1, '--role', 'admin', '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Adding 1 administrator to domain" | ||
r.stdout.should match "done" | ||
client.find_domain(domain.id).members.any?{ |m| m.id == other_users[user1].id && m.admin? }.should be_true | ||
|
||
r = rhc 'add-member', user2, '--role', 'view', '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Adding 1 viewer to domain" | ||
r.stdout.should match "done" | ||
client.find_domain(domain.id).members.any?{ |m| m.id == other_users[user2].id && m.viewer? }.should be_true | ||
|
||
r = rhc 'show-domain', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Members:" | ||
r.stdout.should match "#{user1} \\(admin\\)" | ||
r.stdout.should match "#{user2} \\(view\\)" | ||
|
||
r = rhc 'leave-domain', domain.id, :as => other_users[user2] | ||
r.status.should == 0 | ||
r.stdout.should match "Leaving domain.*done" | ||
end | ||
|
||
it "should remove all non owners" do | ||
user1, user2 = other_users.keys.take(2) | ||
r = rhc 'add-member', user1, user2, '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Adding 2 editors to domain" | ||
r.stdout.should match "done" | ||
members = client.find_domain(domain.id).members | ||
members.any?{ |m| m.id == other_users[user1].id && m.editor? }.should be_true | ||
members.any?{ |m| m.id == other_users[user2].id && m.editor? }.should be_true | ||
|
||
r = rhc 'remove-member', domain.id, '--all' | ||
r.status.should == 0 | ||
r.stdout.should match "Removing all members from domain.*done" | ||
members = client.find_domain(domain.id).members | ||
members.select(&:owner).should == members | ||
end | ||
|
||
it "should reject a non-existent user" do | ||
r = rhc 'add-member', 'not-a-user', '-n', domain.id | ||
r.status.should_not == 1 | ||
r.stdout.should match "There is no account with login not-a-user." | ||
client.find_domain(domain.id).members.length.should == 1 | ||
end | ||
|
||
it "should add a user by id" do | ||
user = other_users.values.take(1).first | ||
r = rhc 'add-member', user.id, '--ids', '-n', domain.id | ||
r.status.should == 0 | ||
r.stdout.should match "Adding 1 editor to domain" | ||
r.stdout.should match "done" | ||
client.find_domain(domain.id).members.any?{ |m| m.id == user.id && m.editor? }.should be_true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
require 'base64' | ||
|
||
module RHC::Auth | ||
class TokenStore | ||
def initialize(dir) | ||
|
Oops, something went wrong.