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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef0616d8ecd08c4ef9bda30c78c7d7cbf642919a
4
- data.tar.gz: 640fe2aecf21bf96c7cadfff3b94448b8b941d6d
3
+ metadata.gz: f66899f6fd9ad80b2db7d45dd458bb0cfd2dfa9a
4
+ data.tar.gz: d9a936fcea3a8071ce6dd85350779db6a99d8d8b
5
5
  SHA512:
6
- metadata.gz: c86faa58db661b782c2da2a4d6a1d4e7d7be82f70ee0bee1021ea86db97ad7335ce14142246a2986e33d6351bca4f604cc5b495585db1eeede2cf7c11a54bf25
7
- data.tar.gz: 44d84572bab3b64791c46d0a4192d082e62a3a51ee7f38821a145dfc5d86bb7c6ffad54a9310d61570e9cbe6d13e0b94b6685d4961fb88be5c4f27c5e1ebe79f
6
+ metadata.gz: 287c927a830bc7a9e4b21c05a2620b12e36861cfb6cffdca02375c7f4cb62c82478863e12a6d2d59e7d60f179889dfc6cdbb6fa73a7aa38fa25158f91b842213
7
+ data.tar.gz: a6f49c682c6ff408775b58802d6faebfb634fce7684a582518c34d19684426997e2f0c5cef6de00f6e2c754e6431ca21fe53168b3c168c4131c3a7c86043af2d
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ db/*.sqlite3
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --format progress
2
+ --format documentation
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in rubycas-server-activerecord.gemspec
4
4
  gemspec
5
5
 
6
-
6
+ gem 'coveralls', require: false
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::Server::Core::Database
6
- extend self
7
- def setup(config_file)
8
- return true
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 = true
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 = true
24
+ self.consumed = Time.zone.now
24
25
  self.save
25
26
  end
26
27
  end
@@ -1,7 +1,7 @@
1
1
  module RubyCAS
2
2
  module Server
3
3
  module Core
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  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
- consumed: Time.at(rand * Time.now.to_i)
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
@@ -1,3 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
1
3
  require "rubycas/server/activerecord"
2
4
  require "rubycas/server/activerecord/model/login_ticket"
3
5
  require 'rspec'
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.1
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-03-31 00:00:00.000000000 Z
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: {}