-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make #auth_url a private Method separate from #swift.
In order to test the private mechanisms within more easily, pull the auth_url construction out of the private method #swift. Add tests for it as well as for #uri_to_object_path, and to make sure #initialize sets the container name correctly. Add fog-openstack and mime-types to the gemspec.
- Loading branch information
Showing
3 changed files
with
65 additions
and
17 deletions.
There are no files selected for viewing
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
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
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,18 +1,64 @@ | ||
require "util/object_storage/miq_swift_storage" | ||
|
||
describe MiqSwiftStorage do | ||
before(:each) do | ||
@uri = "swift://foo.com/abc/def" | ||
@object_storage = described_class.new(:uri => @uri, :username => 'user', :password => 'pass', :region => 'region') | ||
end | ||
context "using a uri without query parameters" do | ||
let(:uri) { "swift://foo.com/abc/def" } | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } | ||
|
||
it "#initialize sets the container_name" do | ||
container_name = object_storage.container_name | ||
expect(container_name).to eq("abc/def") | ||
end | ||
|
||
it "#initialize sets the container_name" do | ||
container_name = @object_storage.container_name | ||
expect(container_name).to eq("abc/def") | ||
it "#uri_to_object_path returns a new object path" do | ||
result = object_storage.uri_to_object_path(uri) | ||
expect(result).to eq("def") | ||
end | ||
end | ||
|
||
it "#uri_to_object_path returns a new object path" do | ||
result = @object_storage.uri_to_object_path(@uri) | ||
expect(result).to eq("def") | ||
describe "#auth_url (private)" do | ||
context "with non-ssl security protocol" do | ||
let(:uri) { "swift://foo.com:5678/abc/def?region=region&api_version=v3&security_protocol=non-ssl" } | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } | ||
|
||
it "sets the scheme to http" do | ||
expect(URI(object_storage.send(:auth_url)).scheme).to eq("http") | ||
end | ||
|
||
it "sets the host to foo.com" do | ||
expect(URI(object_storage.send(:auth_url)).host).to eq("foo.com") | ||
end | ||
end | ||
|
||
context "with ssl security protocol" do | ||
let(:uri) { "swift://foo.com:5678/abc/def?region=region&api_version=v3&security_protocol=ssl" } | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } | ||
|
||
it "sets the scheme to https" do | ||
expect(URI(object_storage.send(:auth_url)).scheme).to eq("https") | ||
end | ||
|
||
it "sets the host to foo.com" do | ||
expect(URI(object_storage.send(:auth_url)).host).to eq("foo.com") | ||
end | ||
end | ||
|
||
context "with v3 api version" do | ||
let(:uri) { "swift://foo.com:5678/abc/def?region=region&api_version=v3&security_protocol=ssl" } | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } | ||
|
||
it "sets the path to a v3 path" do | ||
expect(URI(object_storage.send(:auth_url)).path).to eq("/v3/auth/tokens") | ||
end | ||
end | ||
|
||
context "with v2 api version" do | ||
let(:uri) { "swift://foo.com:5678/abc/def?region=region&api_version=v2&security_protocol=ssl" } | ||
let(:object_storage) { described_class.new(:uri => uri, :username => 'user', :password => 'pass') } | ||
|
||
it "sets the path to a v2 path" do | ||
expect(URI(object_storage.send(:auth_url)).path).to eq("/v2.0/tokens") | ||
end | ||
end | ||
end | ||
end |