Sha256: 4ca234cb5ae8d7bb48af843973c8cbb2e8946afd8728f49116b53241719304f2

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 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 "/api/admin/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 get deprecation warning for get_api_token method" do
      post "/api/admin/login", :login => 'rhoadmin',:password => ''
      post "/api/admin/get_api_token"
      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 "/api/admin/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 "/api/user/create_user", params
      last_response.status.should == 422
    end
    
    it "response should have cache-control and pragma headers set to no-cache" do
      post "/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.2.1 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.2.0 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.2.0.beta5 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.2.0.beta4 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.2.0.beta3 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.2.0.beta2 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.2.0.beta1 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.1.2 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.1.1 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.1.0 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.1.0.beta2 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.1.0.beta1 spec/api/admin/get_api_token_spec.rb
rhoconnect-3.0.6 spec/api/admin/get_api_token_spec.rb