rubycas-server-activerecord 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/Gemfile +1 -1
- data/Rakefile +8 -0
- data/lib/rubycas/server/activerecord.rb +13 -6
- data/lib/rubycas/server/activerecord/model/login_ticket.rb +3 -2
- data/lib/rubycas/server/activerecord/model/service_ticket.rb +3 -2
- data/lib/rubycas/server/activerecord/version.rb +1 -1
- data/rubycas-server-activerecord.gemspec +1 -1
- data/spec/rubycas-server-activerecord_spec.rb +40 -1
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f66899f6fd9ad80b2db7d45dd458bb0cfd2dfa9a
|
4
|
+
data.tar.gz: d9a936fcea3a8071ce6dd85350779db6a99d8d8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 287c927a830bc7a9e4b21c05a2620b12e36861cfb6cffdca02375c7f4cb62c82478863e12a6d2d59e7d60f179889dfc6cdbb6fa73a7aa38fa25158f91b842213
|
7
|
+
data.tar.gz: a6f49c682c6ff408775b58802d6faebfb634fce7684a582518c34d19684426997e2f0c5cef6de00f6e2c754e6431ca21fe53168b3c168c4131c3a7c86043af2d
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--color
|
2
|
-
--format
|
2
|
+
--format documentation
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -7,4 +7,12 @@ RSpec::Core::RakeTask.new(:spec)
|
|
7
7
|
desc 'Run specs'
|
8
8
|
task :default => :spec
|
9
9
|
|
10
|
+
task :migrate do
|
11
|
+
ActiveRecord::Base.establish_connection(
|
12
|
+
adapter: "sqlite3",
|
13
|
+
database: "db/development.sqlite3"
|
14
|
+
)
|
15
|
+
ActiveRecord::Migrator.migrate('db/migrate')
|
16
|
+
end
|
17
|
+
|
10
18
|
|
@@ -1,10 +1,17 @@
|
|
1
1
|
require "active_record"
|
2
|
-
require "rubycas/server/activerecord/model"
|
3
|
-
require "rubycas/server/activerecord/version"
|
4
2
|
|
5
|
-
module RubyCAS
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module RubyCAS
|
4
|
+
module Server
|
5
|
+
module Core
|
6
|
+
module Database
|
7
|
+
extend self
|
8
|
+
def setup(config_file)
|
9
|
+
return true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
15
|
+
|
16
|
+
require "rubycas/server/activerecord/model"
|
17
|
+
require "rubycas/server/activerecord/version"
|
@@ -13,12 +13,13 @@ module RubyCAS::Server::Core::Tickets
|
|
13
13
|
lifetime = Time.now.to_i - created_at.to_time.to_i
|
14
14
|
lifetime > max_lifetime
|
15
15
|
end
|
16
|
+
|
16
17
|
def consumed?
|
17
|
-
consumed
|
18
|
+
consumed.nil? ? false : true
|
18
19
|
end
|
19
20
|
|
20
21
|
def consume!
|
21
|
-
consumed =
|
22
|
+
self.consumed = Time.zone.now
|
22
23
|
self.save
|
23
24
|
end
|
24
25
|
end
|
@@ -15,12 +15,13 @@ module RubyCAS::Server::Core::Tickets
|
|
15
15
|
lifetime = Time.now.to_i - created_at.to_time.to_i
|
16
16
|
lifetime > max_lifetime
|
17
17
|
end
|
18
|
+
|
18
19
|
def consumed?
|
19
|
-
consumed
|
20
|
+
consumed.nil? ? false : true
|
20
21
|
end
|
21
22
|
|
22
23
|
def consume!
|
23
|
-
consumed =
|
24
|
+
self.consumed = Time.zone.now
|
24
25
|
self.save
|
25
26
|
end
|
26
27
|
end
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["vasilakisfil@gmail.com"]
|
11
11
|
spec.description = %q{Activerecord adapter for RubyCAS Server}
|
12
12
|
spec.summary = spec.description
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://www.kollegorna.se"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -135,7 +135,8 @@ describe RubyCAS::Server::Core::Tickets do
|
|
135
135
|
@service_ticket = @ticket_granting_ticket.service_tickets.build(
|
136
136
|
ticket: "Example Ticket",
|
137
137
|
service: "Example Service",
|
138
|
-
|
138
|
+
username: "Example username",
|
139
|
+
client_hostname: "Example client hostname"
|
139
140
|
)
|
140
141
|
end
|
141
142
|
|
@@ -163,6 +164,44 @@ describe RubyCAS::Server::Core::Tickets do
|
|
163
164
|
@service_ticket.ticket_granting_ticket_id = nil
|
164
165
|
expect(@service_ticket).not_to be_valid
|
165
166
|
end
|
167
|
+
|
168
|
+
it "is not consumed at first" do
|
169
|
+
expect(@service_ticket.consumed?).to be_false
|
170
|
+
end
|
171
|
+
require 'rubycas/server/activerecord/model/ticket'
|
172
|
+
#require 'rubycas/server/activerecord/model/consumable'
|
173
|
+
|
174
|
+
module RubyCAS::Server::Core::Tickets
|
175
|
+
class ServiceTicket < ActiveRecord::Base
|
176
|
+
include RubyCAS::Server::Core::Ticket
|
177
|
+
#include RubyCAS::Server::Core::Consumable
|
178
|
+
|
179
|
+
has_one :proxy_granting_ticket
|
180
|
+
belongs_to :ticket_granting_ticket
|
181
|
+
|
182
|
+
validates :ticket, :service, :ticket_granting_ticket_id, presence: true
|
183
|
+
|
184
|
+
def expired?(max_lifetime)
|
185
|
+
lifetime = Time.now.to_i - created_at.to_time.to_i
|
186
|
+
lifetime > max_lifetime
|
187
|
+
end
|
188
|
+
|
189
|
+
def consumed?
|
190
|
+
consumed.nil? ? false : true
|
191
|
+
end
|
192
|
+
|
193
|
+
def consume!
|
194
|
+
self.consumed = DateTime.now
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
context "Service ticket consumption" do
|
199
|
+
it "when consumed #consumed? returns true" do
|
200
|
+
@service_ticket.consume!
|
201
|
+
expect(@service_ticket.consumed?).to eq true
|
202
|
+
expect(@service_ticket.consumed.to_s).to eq DateTime.now.to_s
|
203
|
+
end
|
204
|
+
end
|
166
205
|
end
|
167
206
|
|
168
207
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycas-server-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filippos Vasilakis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -112,7 +112,7 @@ files:
|
|
112
112
|
- rubycas-server-activerecord.gemspec
|
113
113
|
- spec/rubycas-server-activerecord_spec.rb
|
114
114
|
- spec/spec_helper.rb
|
115
|
-
homepage:
|
115
|
+
homepage: http://www.kollegorna.se
|
116
116
|
licenses:
|
117
117
|
- MIT
|
118
118
|
metadata: {}
|