Created
April 28, 2010 19:08
-
-
Save mrkurt/382564 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'spec_helper' | |
describe OauthController do | |
before(:all) do | |
@consumer = Factory.create(:oauth_consumer) | |
end | |
context 'serving an xauth token request to a valid consumer' do | |
before(:all) do | |
@user = Factory.create(:user) | |
header "Authorization", "Token token=\"#{@consumer.tokens.first.key}\"" | |
post '/oauth/access_token', {'x_auth_username' => @user.username, 'x_auth_password' => @user.password, 'x_auth_mode' => 'client_auth' } | |
@user.reload | |
end | |
it "should be successful" do | |
last_response.should be_ok | |
end | |
it "should create a token for the user" do | |
@user.tokens.count.should == 1 | |
end | |
it "should associate the new token with a consumer" do | |
@user.tokens.first.consumer_id.should == @consumer.id | |
end | |
it "should return a token" do | |
last_response.body.should include("oauth_token=#{@user.tokens.first.key}&") | |
end | |
end | |
context 'serving an xauth token request without a consumer token' do | |
before(:all) do | |
@user = Factory.create(:user) | |
header "Authorization", "Token token=\"this-shouldnt-work\"" | |
post '/oauth/access_token', {'x_auth_username' => @user.username, 'x_auth_password' => @user.password, 'x_auth_mode' => 'client_auth' } | |
@user.reload | |
end | |
it "shouldn't be successful" do | |
last_response.should_not be_ok | |
end | |
it "shouldn't add a user token" do | |
@user.tokens.count.should == 0 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment