f1api 0.9.2 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +40 -16
- data/Rakefile +0 -19
- data/config/f1-oauth.yml +4 -4
- data/lib/f1api.rb +1 -3
- data/lib/f1api/activeresource/base.rb +8 -5
- data/lib/f1api/activeresource/connection.rb +16 -13
- data/lib/f1api/client.rb +25 -4
- data/lib/f1api/configuration.rb +29 -17
- data/lib/f1api/oauth.rb +8 -10
- data/lib/f1api/oauth/credentials_authentication.rb +54 -54
- data/lib/f1api/oauth/oauth_authentication.rb +7 -6
- data/test/unit/credentials_test.rb +3 -2
- data/test/unit/oauth_test.rb +3 -1
- metadata +62 -121
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -27
- data/VERSION +0 -1
- data/VERSION.yml +0 -5
- data/f1api.gemspec +0 -89
data/README.md
CHANGED
@@ -1,24 +1,48 @@
|
|
1
1
|
Fellowship One REST API Ruby Client Library
|
2
2
|
===========================================
|
3
3
|
|
4
|
-
**NOTE**: This library is of alpha quality. It is not meant for use in production apps. It's definitely not feature complete and it may have bugs.
|
5
|
-
|
6
4
|
Introduction
|
7
5
|
------------
|
8
|
-
This library is an implementation of the Fellowship One REST API.
|
6
|
+
This library is an implementation of the Fellowship One REST API. The library currently abstracts the ActiveRecord class so it can be used to easily model data from the F1 REST API.
|
7
|
+
|
8
|
+
Two Authentication Methods
|
9
|
+
--------------------------
|
10
|
+
The F1 REST API uses two methods to authenticate the user to the API: credentials for 2nd party and OAuth for 3rd party. See the [F1 API Authentication documentation](http://developer.fellowshipone.com/docs/v1/Util/AuthDocs.help).
|
11
|
+
|
12
|
+
### OAuth (2nd or 3rd Party)
|
13
|
+
|
14
|
+
The Fellowship One API implements the OAuth v1.0 standard. OAuth allows you to let Fellowship One handle the authentication and pass back the access tokens to a callback URL in your app.
|
15
|
+
|
16
|
+
client = FellowshipOneAPI::Client.new
|
17
|
+
# To be explicit: client = FellowshipOneAPI::Client.new({:auth_type => :oauth})
|
18
|
+
client.authorize!
|
19
|
+
|
20
|
+
### Credentials (2nd Party)
|
21
|
+
|
22
|
+
To authenticate against the API using credentials the default can be changed in the YAML configuration file or the method of authentication can be explicitly specified on the instantiation of the `FellowshipOneAPI::Client` class. After that, the credentials of the user you are authenticating needs to be passed into the `authorize!` method.
|
23
|
+
|
24
|
+
client = FellowshipOneAPI::Client.new({:auth_type => :credentials})
|
25
|
+
client.authorize! "username", "password"
|
9
26
|
|
10
27
|
Usage
|
11
28
|
-----
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
29
|
+
Install the gem:
|
30
|
+
|
31
|
+
gem install f1api
|
32
|
+
|
33
|
+
Use it in your code:
|
34
|
+
|
35
|
+
require 'f1api'
|
36
|
+
|
37
|
+
class Person < FellowshipOneAPI::Base
|
38
|
+
end
|
39
|
+
|
40
|
+
client.authorize!
|
41
|
+
# If using creds in YAML file:
|
42
|
+
# client.authorize! "username", "password"
|
43
|
+
|
44
|
+
FellowshipOneAPI::Base.connect client
|
45
|
+
|
46
|
+
Person.find(12345)
|
47
|
+
Person.find(:search, :params => {:searchFor => "Dearing", :include => "communications,addresses"})
|
48
|
+
|
data/Rakefile
CHANGED
@@ -17,22 +17,3 @@ task :rdoc do
|
|
17
17
|
`rdoc -x 'test/*'`
|
18
18
|
end
|
19
19
|
|
20
|
-
require 'jeweler'
|
21
|
-
Jeweler::Tasks.new do |gem|
|
22
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
23
|
-
gem.name = "f1api"
|
24
|
-
gem.homepage = "http://github.com/jessedearing/f1api"
|
25
|
-
gem.license = "MIT"
|
26
|
-
gem.summary = %Q{Consume the Fellowship One API in your apps using ActiveResource}
|
27
|
-
gem.description = %Q{Consumes the Fellowship One API in your apps using ActiveResource. Implements 2nd party credentials-based authenticaion and full OAuth implementation. }
|
28
|
-
gem.email = "jdearing@fellowshiptech.com"
|
29
|
-
gem.authors = ["Jesse Dearing"]
|
30
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
31
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
32
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
33
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
34
|
-
gem.add_runtime_dependency 'oauth', '= 0.4.4'
|
35
|
-
gem.add_development_dependency 'mocha'
|
36
|
-
gem.add_runtime_dependency 'activeresource'
|
37
|
-
end
|
38
|
-
Jeweler::RubygemsDotOrgTasks.new
|
data/config/f1-oauth.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
development:
|
2
|
-
consumer_key: ""
|
3
|
-
consumer_secret: ""
|
2
|
+
consumer_key: "2"
|
3
|
+
consumer_secret: "f7d02059-a105-45e0-85c9-7387565f322b"
|
4
4
|
site_url: "https://{church_code}.staging.fellowshiponeapi.com"
|
5
5
|
# Store the church code if you are writing a 2nd Party implementation
|
6
6
|
# Otherwise, you'll want to ask for the church code from the user
|
7
|
-
church_code: "
|
8
|
-
authentication_type: "
|
7
|
+
church_code: "dc"
|
8
|
+
authentication_type: "credentials" #oauth or credentials
|
9
9
|
request_token_path: "/v1/Tokens/RequestToken"
|
10
10
|
access_token_path: "/v1/Tokens/AccessToken" #OAuth only
|
11
11
|
# OAuth authentication vars
|
data/lib/f1api.rb
CHANGED
@@ -7,8 +7,6 @@ require 'uri'
|
|
7
7
|
require 'active_resource'
|
8
8
|
require "f1api/configuration"
|
9
9
|
require "f1api/oauth"
|
10
|
-
require "f1api/oauth/credentials_authentication"
|
11
|
-
require "f1api/oauth/oauth_authentication"
|
12
10
|
require "f1api/client"
|
13
11
|
require "f1api/activeresource/connection"
|
14
|
-
require "f1api/activeresource/base"
|
12
|
+
require "f1api/activeresource/base"
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module FellowshipOneAPI # :nodoc:
|
2
2
|
# The Base class should be inherited by all model classes as it provides the facilities that the class will need
|
3
3
|
class Base < ActiveResource::Base
|
4
|
-
self.site = "#{Configuration.site_url}/v1"
|
5
4
|
# Creates a new connection
|
6
|
-
#
|
5
|
+
#
|
7
6
|
# ==Examples
|
8
7
|
# Person.connect(FellowshipOneAPI::Client.new)
|
9
|
-
#
|
8
|
+
#
|
10
9
|
# If the connection needs to be forcibly refreshed then you can pass true
|
11
10
|
# Person.connect(FellowshipOneAPI::Client.new, true)
|
12
11
|
def self.connect(client, refresh = false)
|
@@ -14,6 +13,10 @@ module FellowshipOneAPI # :nodoc:
|
|
14
13
|
@connection = Connection.new(client, client.consumer.site, format)
|
15
14
|
end
|
16
15
|
end
|
17
|
-
|
16
|
+
|
17
|
+
# Setting site from configuration
|
18
|
+
self.site = "#{FellowshipOneAPI::Configuration.site_url}/v1"
|
19
|
+
# Setting mode to JSON
|
20
|
+
self.format = :json
|
18
21
|
end
|
19
|
-
end
|
22
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
2
|
|
3
3
|
module FellowshipOneAPI
|
4
4
|
# Creating a wrapper for the ActiveResource::Connection class
|
@@ -8,7 +8,7 @@ module FellowshipOneAPI
|
|
8
8
|
@f1api_connection = f1api_connection
|
9
9
|
super(*args)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
private
|
13
13
|
# The request method that is passes the request through to the F1 API client
|
14
14
|
def request(method, path, *args)
|
@@ -16,24 +16,27 @@ module FellowshipOneAPI
|
|
16
16
|
super(method, path, *args)
|
17
17
|
else
|
18
18
|
response = @f1api_connection.request(method, path, *args)
|
19
|
-
|
20
19
|
if method == :get
|
21
20
|
response.body = transform_response response.body, path
|
22
21
|
end
|
23
22
|
handle_response(response)
|
24
23
|
end
|
25
24
|
end
|
26
|
-
|
27
|
-
#
|
25
|
+
|
28
26
|
def transform_response(response_body, path)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
json = JSON.parse(response_body)
|
28
|
+
if json.keys.first == "results"
|
29
|
+
json = json["results"]
|
30
|
+
key = json.keys.find {|k| k[0] != '@'}
|
31
|
+
key = key.first if key.is_a? Enumerator
|
32
|
+
ret = []
|
33
|
+
json[key].each do |person|
|
34
|
+
ret << person
|
35
|
+
end
|
36
|
+
JSON.dump({"people" => ret})
|
37
|
+
else
|
38
|
+
JSON.dump(json[json.keys.first])
|
34
39
|
end
|
35
|
-
|
36
|
-
n.to_s
|
37
40
|
end
|
38
41
|
end
|
39
|
-
end
|
42
|
+
end
|
data/lib/f1api/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module FellowshipOneAPI
|
2
4
|
# ==The Fellowship One API client class
|
3
5
|
# Takes an HTTP request and passes it through the OAuth library which added the approperiate headers and querystring
|
@@ -38,25 +40,44 @@ module FellowshipOneAPI
|
|
38
40
|
def initialize(args = {})
|
39
41
|
args[:auth_type] ||= Configuration.authentication_type.to_sym
|
40
42
|
if args[:auth_type] == :credentials
|
43
|
+
require "#{File.dirname(__FILE__)}/oauth/credentials_authentication"
|
41
44
|
extend OAuth::CredentialsAuthentication
|
42
45
|
else
|
46
|
+
require "#{File.dirname(__FILE__)}/oauth/oauth_authentication"
|
43
47
|
extend OAuth::OAuthAuthentication
|
44
48
|
end
|
45
|
-
|
49
|
+
|
46
50
|
if(args[:auth_against])
|
47
51
|
load_consumer_config args[:auth_against]
|
48
52
|
else
|
49
53
|
load_consumer_config
|
50
54
|
end
|
51
|
-
|
55
|
+
|
52
56
|
if(args[:oauth_token] and args[:oauth_token_secret])
|
53
57
|
@oauth_access_token = ::OAuth::AccessToken.from_hash(@oauth_consumer, args[:oauth_token], args[:oauth_token_secret])
|
54
58
|
end
|
59
|
+
|
60
|
+
if(args[:auth_username] and args[:auth_password])
|
61
|
+
authorize! args[:auth_username], args[:auth_password]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Lazy loads the user record you've logged in as
|
66
|
+
def current_user
|
67
|
+
if @current_user.nil?
|
68
|
+
req = request(:get, "#{@authenticated_user_uri}.json")
|
69
|
+
if req.code.to_i == 200
|
70
|
+
@current_user = JSON.parse(req.body)["person"]
|
71
|
+
else
|
72
|
+
raise "Non HTTP 200 on current_user load"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
@current_user
|
55
76
|
end
|
56
|
-
|
77
|
+
|
57
78
|
# Passes through the request to the OAuth library to be signed and set out HTTP
|
58
79
|
def request(*args)
|
59
80
|
@oauth_access_token.request(*args)
|
60
81
|
end
|
61
82
|
end
|
62
|
-
end
|
83
|
+
end
|
data/lib/f1api/configuration.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
module FellowshipOneAPI # :nodoc:
|
2
2
|
# This accesses the YAML-based F1 API config file
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# This class was written to take rails environment variables like +RAILS_ENV+ and +Rails.root+ into account
|
5
5
|
class Configuration
|
6
6
|
# Explictly defines where the configuration file is
|
7
7
|
def self.file_path=(path)
|
8
|
-
@
|
8
|
+
@config_yaml = nil
|
9
|
+
@file_path = path
|
9
10
|
end
|
10
|
-
|
11
|
+
|
12
|
+
# Reload the configuration file
|
13
|
+
def self.reload
|
14
|
+
load_yaml
|
15
|
+
end
|
16
|
+
|
11
17
|
# Gets the specified key from the configuration file
|
12
18
|
# [Example] FellowshipTechAPIClient.Configuration["consumer_key"] <i># "2"</i>
|
13
19
|
#
|
@@ -21,42 +27,48 @@ module FellowshipOneAPI # :nodoc:
|
|
21
27
|
end
|
22
28
|
return val
|
23
29
|
end
|
24
|
-
|
30
|
+
|
25
31
|
# Gets the current environment
|
26
32
|
def self.environment
|
27
33
|
@environment ||= "development"
|
28
34
|
@environment ||= ::Rails.env if defined? ::Rails
|
29
35
|
@environment
|
30
36
|
end
|
31
|
-
|
37
|
+
|
32
38
|
# Set the current environment
|
33
39
|
def self.environment=(env_value)
|
34
40
|
@environment = env_value
|
35
41
|
end
|
36
|
-
|
42
|
+
|
37
43
|
# Overridden method_missing to facilitate a more pleasing ruby-like syntax for accessing
|
38
44
|
# configuration values
|
39
45
|
def self.method_missing(name, *args, &block)
|
40
46
|
return self[name.to_s] unless self[name.to_s].nil?
|
41
47
|
super
|
42
48
|
end
|
43
|
-
|
49
|
+
|
44
50
|
private
|
45
|
-
|
51
|
+
|
46
52
|
# Loads the YAML file
|
47
53
|
#
|
48
54
|
# Starts by looking to see if file_path is defined then checks in current directory (.) and then your Rails.root and then the config
|
49
55
|
# directory off of the base directory of the gem
|
50
56
|
def self.load_yaml
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
begin
|
58
|
+
if not @file_path.nil?
|
59
|
+
@config_yaml = YAML.load_file(@file_path)
|
60
|
+
elsif File.exists? "./f1-oauth.yml"
|
61
|
+
@config_yaml = YAML.load_file("./f1-oauth.yml")
|
62
|
+
elsif defined? ::Rails
|
63
|
+
@config_yaml = YAML.load_file("#{::Rails.root}/config/f1-oauth.yml")
|
64
|
+
else
|
65
|
+
path = File.dirname(__FILE__) + "/../../config/f1-oauth.yml"
|
66
|
+
@config_yaml = YAML.load_file(path)
|
67
|
+
end
|
68
|
+
true
|
69
|
+
rescue Exception => ex
|
70
|
+
puts "There was an error: #{ex.message}"
|
71
|
+
false
|
60
72
|
end
|
61
73
|
end
|
62
74
|
end
|
data/lib/f1api/oauth.rb
CHANGED
@@ -11,24 +11,24 @@ module FellowshipOneAPI # :nodoc:
|
|
11
11
|
attr_accessor :oauth_consumer_key
|
12
12
|
alias :consumer_key :oauth_consumer_key
|
13
13
|
alias :consumer_key= :oauth_consumer_key=
|
14
|
-
|
14
|
+
|
15
15
|
# The OAuth consumer secret.
|
16
16
|
# This will get set automatically from the YAML config file if not set explictly
|
17
17
|
attr_accessor :oauth_consumer_secret
|
18
18
|
alias :consumer_secret :oauth_consumer_secret
|
19
19
|
alias :consumer_secret= :oauth_consumer_secret=
|
20
|
-
|
20
|
+
|
21
21
|
# The OAuth access token object where all requests are made off of
|
22
22
|
attr_reader :oauth_access_token
|
23
23
|
alias :access_token :oauth_access_token
|
24
|
-
|
24
|
+
|
25
25
|
# The OAuth consumer object
|
26
26
|
attr_reader :oauth_consumer
|
27
27
|
alias :consumer :oauth_consumer
|
28
|
-
|
28
|
+
|
29
29
|
# The URI for the resource of the authenticated user
|
30
30
|
attr_reader :authenticated_user_uri
|
31
|
-
|
31
|
+
|
32
32
|
# Creates the OAuth consumer object
|
33
33
|
def load_consumer_config(type = :portal)
|
34
34
|
case type
|
@@ -37,10 +37,10 @@ module FellowshipOneAPI # :nodoc:
|
|
37
37
|
when :weblink
|
38
38
|
authorize_path = FellowshipOneAPI::Configuration.weblink_authorize_path
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
@oauth_consumer_key ||= FellowshipOneAPI::Configuration.consumer_key
|
42
42
|
@oauth_consumer_secret ||= FellowshipOneAPI::Configuration.consumer_secret
|
43
|
-
|
43
|
+
|
44
44
|
@oauth_consumer = ::OAuth::Consumer.new(@oauth_consumer_key,
|
45
45
|
@oauth_consumer_secret,
|
46
46
|
{:site => FellowshipOneAPI::Configuration.site_url,
|
@@ -48,7 +48,5 @@ module FellowshipOneAPI # :nodoc:
|
|
48
48
|
:access_token_path => FellowshipOneAPI::Configuration.access_token_path,
|
49
49
|
:authorize_path => authorize_path })
|
50
50
|
end
|
51
|
-
|
52
|
-
|
53
51
|
end
|
54
|
-
end
|
52
|
+
end
|
@@ -1,59 +1,59 @@
|
|
1
1
|
module FellowshipOneAPI # :nodoc:
|
2
2
|
module OAuth
|
3
|
-
|
3
|
+
# Implements the Credentials method of authentication. You must manage the credentials.
|
4
4
|
module CredentialsAuthentication
|
5
5
|
include OAuth
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
6
|
+
# Authorizes a user
|
7
|
+
# +username+:: The username of the user
|
8
|
+
# +password+:: The password of the user
|
9
|
+
# +type+:: Can be :portal or :weblink based on which credentials you want to authenticate against
|
10
|
+
# Returns the URI for the authenticated user
|
11
|
+
def authenticate!(username, password, type = :portal)
|
12
|
+
load_consumer_config(type) if @oauth_consumer.nil?
|
13
|
+
|
14
|
+
cred = URI.encode(Base64.encode64("#{username} #{password}"))
|
15
|
+
|
16
|
+
case type
|
17
|
+
when :portal
|
18
|
+
auth_url = FellowshipOneAPI::Configuration.portal_credential_token_path
|
19
|
+
when :weblink
|
20
|
+
auth_url = FellowshipOneAPI::Configuration.weblink_credential_token_path
|
21
|
+
end
|
22
|
+
|
23
|
+
response = @oauth_consumer.request(:post, auth_url, nil, {}, "ec=#{cred}", {'Content-Type' => 'application/x-www-form-urlencoded'})
|
24
|
+
|
25
|
+
handle_response_code(response)
|
26
|
+
|
27
|
+
# Gettting the URI of the authenticated user
|
28
|
+
@authenticated_user_uri = response["Content-Location"]
|
29
|
+
end
|
30
|
+
alias :authorize! :authenticate!
|
31
|
+
|
32
|
+
private
|
33
|
+
def handle_response_code(response)
|
34
|
+
case response.code.to_i
|
35
|
+
when (200..299)
|
36
|
+
@oauth_access_token = ::OAuth::AccessToken.from_hash(@oauth_consumer, parse_access_token(response.body))
|
37
|
+
when (300..399)
|
38
|
+
# redirect
|
39
|
+
# TODO: actually redirect instead of throwing error
|
40
|
+
response.error!
|
41
|
+
when (400..499)
|
42
|
+
raise OAuth::Unauthorized, response
|
43
|
+
else
|
44
|
+
response.error!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Parse returned OAuth access token key/secret pair
|
49
|
+
def parse_access_token(response)
|
50
|
+
oauth_hash = {}
|
51
|
+
response.split('&').each do |val|
|
52
|
+
kv = val.split('=')
|
53
|
+
oauth_hash.merge!({kv[0].to_sym => kv[1]})
|
54
|
+
end
|
55
|
+
oauth_hash
|
56
|
+
end
|
57
|
+
end
|
58
58
|
end
|
59
|
-
end
|
59
|
+
end
|
@@ -6,16 +6,16 @@ module FellowshipOneAPI # :nodoc:
|
|
6
6
|
include OAuth
|
7
7
|
# The OAuth request object
|
8
8
|
attr_reader :oauth_request
|
9
|
-
|
9
|
+
|
10
10
|
# The OAuth authorization URI
|
11
11
|
attr_reader :oauth_authorize_url
|
12
12
|
alias :authorize_url :oauth_authorize_url
|
13
|
-
|
14
|
-
# Gets a new request token and return the
|
13
|
+
|
14
|
+
# Gets a new request token and return the authenticated URI
|
15
15
|
# +type+:: Can be :portal or :weblink based on which credentials you want to authenticate against
|
16
|
-
def
|
16
|
+
def authenticate!(type = :portal)
|
17
17
|
load_consumer_config(type) if oauth_consumer.nil?
|
18
|
-
|
18
|
+
|
19
19
|
@oauth_request = oauth_consumer.get_request_token
|
20
20
|
@oauth_authorize_url = oauth_request.authorize_url
|
21
21
|
|
@@ -57,6 +57,7 @@ module FellowshipOneAPI # :nodoc:
|
|
57
57
|
|
58
58
|
oauth_authorize_url
|
59
59
|
end
|
60
|
+
alias :authorize! :authenticate!
|
60
61
|
|
61
62
|
# After a the user has been authenticated then we use the access token to access protected resources in the API.
|
62
63
|
# Since the authentication has taken place, we now know about the user that authenticated and
|
@@ -69,4 +70,4 @@ module FellowshipOneAPI # :nodoc:
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
72
|
-
end
|
73
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../lib/f1api/oauth/credentials_authentication"
|
2
|
+
|
1
3
|
class CredentialsAuthenticationTest
|
2
4
|
include FellowshipOneAPI::OAuth::CredentialsAuthentication
|
3
5
|
attr_accessor :oauth_consumer
|
@@ -37,7 +39,6 @@ class CredentialsTest < Test::Unit::TestCase
|
|
37
39
|
cred = URI.encode(Base64.encode64("#{@test_username} #{@test_password}"))
|
38
40
|
@cred_test.oauth_consumer = nil
|
39
41
|
@cred_test.load_consumer_config(:weblink)
|
40
|
-
@cred_test.oauth_consumer.expects(:get_request_token).returns(@mocked_request_token).at_least_once
|
41
42
|
@cred_test.oauth_consumer.expects(:request).with(:post, ::FellowshipOneAPI::Configuration.weblink_credential_token_path,
|
42
43
|
nil, {}, "ec=#{cred}", {'Content-Type' => 'application/x-www-form-urlencoded'}).returns(
|
43
44
|
HttpFixture.new).at_least_once
|
@@ -56,4 +57,4 @@ class CredentialsTest < Test::Unit::TestCase
|
|
56
57
|
|
57
58
|
assert_equal(@mocked_user_uri, @cred_test.authenticated_user_uri)
|
58
59
|
end
|
59
|
-
end
|
60
|
+
end
|
data/test/unit/oauth_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../lib/f1api/oauth/oauth_authentication"
|
2
|
+
|
1
3
|
class OAuthAuthenticationTest
|
2
4
|
include FellowshipOneAPI::OAuth::OAuthAuthentication
|
3
5
|
attr_accessor :oauth_consumer
|
@@ -71,4 +73,4 @@ class OAuthTest < Test::Unit::TestCase
|
|
71
73
|
assert_equal("#{Configuration.site_url}#{Configuration.weblink_authorize_path}", @oauth_test.oauth_consumer.authorize_url)
|
72
74
|
end
|
73
75
|
|
74
|
-
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,136 +1,81 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: f1api
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 9
|
8
|
-
- 2
|
9
|
-
version: 0.9.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.11
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Jesse Dearing
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: nokogiri
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
version: "0"
|
30
|
-
type: :runtime
|
31
|
-
prerelease: false
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-05-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
34
15
|
name: oauth
|
35
|
-
requirement: &
|
16
|
+
requirement: &2156900320 !ruby/object:Gem::Requirement
|
36
17
|
none: false
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 0
|
42
|
-
- 4
|
43
|
-
- 4
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
44
21
|
version: 0.4.4
|
45
22
|
type: :runtime
|
46
23
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: mocha
|
50
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
version: "0"
|
58
|
-
type: :runtime
|
59
|
-
prerelease: false
|
60
|
-
version_requirements: *id003
|
61
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: *2156900320
|
25
|
+
- !ruby/object:Gem::Dependency
|
62
26
|
name: activeresource
|
63
|
-
requirement: &
|
27
|
+
requirement: &2156899900 !ruby/object:Gem::Requirement
|
64
28
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
- 0
|
70
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
71
33
|
type: :runtime
|
72
34
|
prerelease: false
|
73
|
-
version_requirements: *
|
74
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *2156899900
|
36
|
+
- !ruby/object:Gem::Dependency
|
75
37
|
name: oauth
|
76
|
-
requirement: &
|
38
|
+
requirement: &2156899280 !ruby/object:Gem::Requirement
|
77
39
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
segments:
|
82
|
-
- 0
|
83
|
-
- 4
|
84
|
-
- 4
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
85
43
|
version: 0.4.4
|
86
44
|
type: :runtime
|
87
45
|
prerelease: false
|
88
|
-
version_requirements: *
|
89
|
-
- !ruby/object:Gem::Dependency
|
46
|
+
version_requirements: *2156899280
|
47
|
+
- !ruby/object:Gem::Dependency
|
90
48
|
name: mocha
|
91
|
-
requirement: &
|
49
|
+
requirement: &2156898800 !ruby/object:Gem::Requirement
|
92
50
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
- 0
|
98
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
99
55
|
type: :development
|
100
56
|
prerelease: false
|
101
|
-
version_requirements: *
|
102
|
-
- !ruby/object:Gem::Dependency
|
57
|
+
version_requirements: *2156898800
|
58
|
+
- !ruby/object:Gem::Dependency
|
103
59
|
name: activeresource
|
104
|
-
requirement: &
|
60
|
+
requirement: &2156898320 !ruby/object:Gem::Requirement
|
105
61
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
- 0
|
111
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
112
66
|
type: :runtime
|
113
67
|
prerelease: false
|
114
|
-
version_requirements: *
|
115
|
-
description:
|
116
|
-
|
68
|
+
version_requirements: *2156898320
|
69
|
+
description: ! 'Consumes the Fellowship One API in your apps using ActiveResource. Implements
|
70
|
+
2nd party credentials-based authenticaion and full OAuth implementation. '
|
71
|
+
email: jesse.dearing@activenetwork.com
|
117
72
|
executables: []
|
118
|
-
|
119
73
|
extensions: []
|
120
|
-
|
121
|
-
extra_rdoc_files:
|
122
|
-
- LICENSE
|
123
|
-
- README.md
|
124
|
-
files:
|
125
|
-
- Gemfile
|
126
|
-
- Gemfile.lock
|
74
|
+
extra_rdoc_files:
|
127
75
|
- LICENSE
|
128
76
|
- README.md
|
129
|
-
|
130
|
-
- VERSION
|
131
|
-
- VERSION.yml
|
77
|
+
files:
|
132
78
|
- config/f1-oauth.yml
|
133
|
-
- f1api.gemspec
|
134
79
|
- lib/f1api.rb
|
135
80
|
- lib/f1api/activeresource/base.rb
|
136
81
|
- lib/f1api/activeresource/connection.rb
|
@@ -139,45 +84,41 @@ files:
|
|
139
84
|
- lib/f1api/oauth.rb
|
140
85
|
- lib/f1api/oauth/credentials_authentication.rb
|
141
86
|
- lib/f1api/oauth/oauth_authentication.rb
|
87
|
+
- LICENSE
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
142
90
|
- test/fixtures/access_token.rb
|
143
91
|
- test/fixtures/http.rb
|
144
92
|
- test/fixtures/request_token.rb
|
145
93
|
- test/unit/configuration_test.rb
|
146
94
|
- test/unit/credentials_test.rb
|
147
95
|
- test/unit/oauth_test.rb
|
148
|
-
has_rdoc: true
|
149
96
|
homepage: http://github.com/jessedearing/f1api
|
150
|
-
licenses:
|
97
|
+
licenses:
|
151
98
|
- MIT
|
152
99
|
post_install_message:
|
153
100
|
rdoc_options: []
|
154
|
-
|
155
|
-
require_paths:
|
101
|
+
require_paths:
|
156
102
|
- lib
|
157
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
104
|
none: false
|
159
|
-
requirements:
|
160
|
-
- -
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
|
163
|
-
|
164
|
-
version: "0"
|
165
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
110
|
none: false
|
167
|
-
requirements:
|
168
|
-
- -
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
|
171
|
-
- 0
|
172
|
-
version: "0"
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
173
115
|
requirements: []
|
174
|
-
|
175
116
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.
|
117
|
+
rubygems_version: 1.7.2
|
177
118
|
signing_key:
|
178
119
|
specification_version: 3
|
179
120
|
summary: Consume the Fellowship One API in your apps using ActiveResource
|
180
|
-
test_files:
|
121
|
+
test_files:
|
181
122
|
- test/fixtures/access_token.rb
|
182
123
|
- test/fixtures/http.rb
|
183
124
|
- test/fixtures/request_token.rb
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (3.0.3)
|
5
|
-
activesupport (= 3.0.3)
|
6
|
-
builder (~> 2.1.2)
|
7
|
-
i18n (~> 0.4)
|
8
|
-
activeresource (3.0.3)
|
9
|
-
activemodel (= 3.0.3)
|
10
|
-
activesupport (= 3.0.3)
|
11
|
-
activesupport (3.0.3)
|
12
|
-
builder (2.1.2)
|
13
|
-
i18n (0.4.2)
|
14
|
-
mocha (0.9.9)
|
15
|
-
rake
|
16
|
-
nokogiri (1.4.4)
|
17
|
-
oauth (0.4.4)
|
18
|
-
rake (0.8.7)
|
19
|
-
|
20
|
-
PLATFORMS
|
21
|
-
ruby
|
22
|
-
|
23
|
-
DEPENDENCIES
|
24
|
-
activeresource
|
25
|
-
mocha
|
26
|
-
nokogiri
|
27
|
-
oauth (= 0.4.4)
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.0
|
data/VERSION.yml
DELETED
data/f1api.gemspec
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{f1api}
|
8
|
-
s.version = "0.9.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jesse Dearing"]
|
12
|
-
s.date = %q{2010-11-19}
|
13
|
-
s.description = %q{Consumes the Fellowship One API in your apps using ActiveResource. Implements 2nd party credentials-based authenticaion and full OAuth implementation. }
|
14
|
-
s.email = %q{jdearing@fellowshiptech.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"LICENSE",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"VERSION.yml",
|
27
|
-
"config/f1-oauth.yml",
|
28
|
-
"f1api.gemspec",
|
29
|
-
"lib/f1api.rb",
|
30
|
-
"lib/f1api/activeresource/base.rb",
|
31
|
-
"lib/f1api/activeresource/connection.rb",
|
32
|
-
"lib/f1api/client.rb",
|
33
|
-
"lib/f1api/configuration.rb",
|
34
|
-
"lib/f1api/oauth.rb",
|
35
|
-
"lib/f1api/oauth/credentials_authentication.rb",
|
36
|
-
"lib/f1api/oauth/oauth_authentication.rb",
|
37
|
-
"test/fixtures/access_token.rb",
|
38
|
-
"test/fixtures/http.rb",
|
39
|
-
"test/fixtures/request_token.rb",
|
40
|
-
"test/unit/configuration_test.rb",
|
41
|
-
"test/unit/credentials_test.rb",
|
42
|
-
"test/unit/oauth_test.rb"
|
43
|
-
]
|
44
|
-
s.homepage = %q{http://github.com/jessedearing/f1api}
|
45
|
-
s.licenses = ["MIT"]
|
46
|
-
s.require_paths = ["lib"]
|
47
|
-
s.rubygems_version = %q{1.3.7}
|
48
|
-
s.summary = %q{Consume the Fellowship One API in your apps using ActiveResource}
|
49
|
-
s.test_files = [
|
50
|
-
"test/fixtures/access_token.rb",
|
51
|
-
"test/fixtures/http.rb",
|
52
|
-
"test/fixtures/request_token.rb",
|
53
|
-
"test/unit/configuration_test.rb",
|
54
|
-
"test/unit/credentials_test.rb",
|
55
|
-
"test/unit/oauth_test.rb"
|
56
|
-
]
|
57
|
-
|
58
|
-
if s.respond_to? :specification_version then
|
59
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
-
s.specification_version = 3
|
61
|
-
|
62
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
64
|
-
s.add_runtime_dependency(%q<oauth>, ["= 0.4.4"])
|
65
|
-
s.add_runtime_dependency(%q<mocha>, [">= 0"])
|
66
|
-
s.add_runtime_dependency(%q<activeresource>, [">= 0"])
|
67
|
-
s.add_runtime_dependency(%q<oauth>, ["= 0.4.4"])
|
68
|
-
s.add_development_dependency(%q<mocha>, [">= 0"])
|
69
|
-
s.add_runtime_dependency(%q<activeresource>, [">= 0"])
|
70
|
-
else
|
71
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
72
|
-
s.add_dependency(%q<oauth>, ["= 0.4.4"])
|
73
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
74
|
-
s.add_dependency(%q<activeresource>, [">= 0"])
|
75
|
-
s.add_dependency(%q<oauth>, ["= 0.4.4"])
|
76
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
77
|
-
s.add_dependency(%q<activeresource>, [">= 0"])
|
78
|
-
end
|
79
|
-
else
|
80
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
81
|
-
s.add_dependency(%q<oauth>, ["= 0.4.4"])
|
82
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
83
|
-
s.add_dependency(%q<activeresource>, [">= 0"])
|
84
|
-
s.add_dependency(%q<oauth>, ["= 0.4.4"])
|
85
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
86
|
-
s.add_dependency(%q<activeresource>, [">= 0"])
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|