spec/lib/api_spec.rb in conjur-api-4.6.1 vs spec/lib/api_spec.rb in conjur-api-4.7.1
- old
+ new
@@ -212,9 +212,18 @@
api.instance_variable_get("@token").should == nil
api.token.should == token
api.credentials.should == { headers: { authorization: "Token token=\"#{Base64.strict_encode64(token.to_json)}\"" }, username: login }
end
end
+ context "from logged-in RestClient::Resource" do
+ let(:token_encoded) { Base64.strict_encode64(token.to_json) }
+ let(:resource) { RestClient::Resource.new("http://example.com", { headers: { authorization: "Token token=\"#{token_encoded}\"" } })}
+ it "can construct a new API instance" do
+ api = resource.conjur_api
+ api.credentials[:headers][:authorization].should == "Token token=\"#{token_encoded}\""
+ api.credentials[:username].should == "bob"
+ end
+ end
end
describe "#role_from_username", logged_in: true do
it "returns a user role when username is plain" do
api.role_from_username("plain-username").roleid.should == "#{account}:user:plain-username"