Sha256: 3ce7aacdda85c8a94254e19872949a83fbb7d65f57777eed9f3bce7eb809453b

Contents?: true

Size: 1.48 KB

Versions: 13

Compression:

Stored size: 1.48 KB

Contents

require File.join(File.dirname(__FILE__),'..','api_helper')

describe "RhoconnectApiGetApiToken" do
  it_should_behave_like "ApiHelper" do
    it "should login and receive the token string" do
      post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
      last_response.body.should == @api_token
    end
    
    it "should login using the old route and show deprecation warning" do
      post "/login", :login => 'rhoadmin',:password => ''
      last_response.body.should == @api_token
      last_response.headers["Warning"].index('deprecated').should_not == nil
    end
    
    it "should fail to login and get token if user is not rhoadmin" do
      Rhoconnect.appserver = nil
      post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => @u_fields[:login],:password => 'testpass'
      last_response.status.should == 422    
      last_response.body.should == 'Invalid/missing API user'
    end  

    it "should return 422 if no token provided" do
      params = {:attributes => {:login => 'testuser1', :password => 'testpass1'}}
      post "/rc/#{Rhoconnect::API_VERSION}/users", params
      last_response.status.should == 422
    end
    
    it "response should have cache-control and pragma headers set to no-cache" do
      post "/rc/#{Rhoconnect::API_VERSION}/system/login", :login => 'rhoadmin',:password => ''
      last_response.headers['Cache-Control'].should == 'no-cache'
      last_response.headers['Pragma'].should == 'no-cache'
    end
  end  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rhoconnect-3.4.5 spec/api/system/login_spec.rb
rhoconnect-3.4.4 spec/api/system/login_spec.rb
rhoconnect-3.4.3 spec/api/system/login_spec.rb
rhoconnect-3.4.2 spec/api/system/login_spec.rb
rhoconnect-3.3.6 spec/api/system/login_spec.rb
rhoconnect-3.3.5 spec/api/system/login_spec.rb
rhoconnect-3.3.4 spec/api/system/login_spec.rb
rhoconnect-3.3.3 spec/api/system/login_spec.rb
rhoconnect-3.3.2 spec/api/system/login_spec.rb
rhoconnect-3.3.1 spec/api/system/login_spec.rb
rhoconnect-3.3.1.beta4 spec/api/system/login_spec.rb
rhoconnect-3.3.1.beta3 spec/api/system/login_spec.rb
rhoconnect-3.3.1.beta2 spec/api/system/login_spec.rb