C0 code coverage information

Generated on Fri Jul 11 15:55:35 -0700 2008 with rcov 0.7.0


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
lib/openid/store/nonce.rb 68 49
100.0% 
100.0% 
 1 require 'openid/cryptutil'
 2 require 'date'
 3 require 'time'
 4 
 5 module OpenID
 6   module Nonce
 7     DEFAULT_SKEW = 60*60*5
 8     TIME_FMT = '%Y-%m-%dT%H:%M:%SZ'
 9     TIME_STR_LEN = '0000-00-00T00:00:00Z'.size
10     @@NONCE_CHRS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
11     TIME_VALIDATOR = /\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/
12 
13     @skew = DEFAULT_SKEW
14 
15     # The allowed nonce time skew in seconds.  Defaults to 5 hours.
16     # Used for checking nonce validity, and by stores' cleanup methods.
17     def Nonce.skew
18       @skew
19     end
20 
21     def Nonce.skew=(new_skew)
22       @skew = new_skew
23     end
24 
25     # Extract timestamp from a nonce string
26     def Nonce.split_nonce(nonce_str)
27       timestamp_str = nonce_str[0...TIME_STR_LEN]
28       raise ArgumentError if timestamp_str.size < TIME_STR_LEN
29       raise ArgumentError unless timestamp_str.match(TIME_VALIDATOR)
30       ts = Time.parse(timestamp_str).to_i
31       raise ArgumentError if ts < 0
32       return ts, nonce_str[TIME_STR_LEN..-1]
33     end
34 
35     # Is the timestamp that is part of the specified nonce string
36     # within the allowed clock-skew of the current time?
37     def Nonce.check_timestamp(nonce_str, allowed_skew=nil, now=nil)
38       allowed_skew = skew if allowed_skew.nil?
39       begin
40         stamp, foo = split_nonce(nonce_str)
41       rescue ArgumentError # bad timestamp
42         return false
43       end
44       now = Time.now.to_i unless now
45 
46       # times before this are too old
47       past = now - allowed_skew
48 
49       # times newer than this are too far in the future
50       future = now + allowed_skew
51 
52       return (past <= stamp and stamp <= future)
53     end
54 
55     # generate a nonce with the specified timestamp (defaults to now)
56     def Nonce.mk_nonce(time = nil)
57       salt = CryptUtil::random_string(6, @@NONCE_CHRS)
58       if time.nil?
59         t = Time.now.getutc
60       else
61         t = Time.at(time).getutc
62       end
63       time_str = t.strftime(TIME_FMT)
64       return time_str + salt
65     end
66 
67   end
68 end

Generated using the rcov code coverage analysis tool for Ruby version 0.7.0.

Valid XHTML 1.0! Valid CSS!