Skip to content

Commit

Permalink
Fix tests on Windows and cleanup CI
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Jul 8, 2024
1 parent f40c59b commit 99ec80d
Show file tree
Hide file tree
Showing 3 changed files with 475 additions and 12 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,29 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest]
ruby-version: [2.1.9, 2.2.10, 2.3.8, 2.4.6, 2.5.8, 2.6.6, 2.7.2, 3.0.1, 3.1, 3.2, jruby-9.1.17.0, jruby-9.2.17.0, jruby-9.3.2.0, jruby-9.4.0.0, truffleruby]
os:
- ubuntu-20.04
- macos-latest
- windows-latest
ruby-version:
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
- 3.1
- 3.2
- jruby-9.1
- jruby-9.2
- jruby-9.3
- jruby-9.4
- truffleruby
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
Expand Down
24 changes: 15 additions & 9 deletions lib/onelogin/ruby-saml/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,26 @@ def self.parse_duration(duration, timestamp=Time.now.utc)
matches = duration.match(DURATION_FORMAT)

if matches.nil?
raise Exception.new("Invalid ISO 8601 duration")
raise StandardError.new("Invalid ISO 8601 duration")
end

sign = matches[1] == '-' ? -1 : 1

durYears, durMonths, durDays, durHours, durMinutes, durSeconds, durWeeks =
matches[2..8].map { |match| match ? sign * match.tr(',', '.').to_f : 0.0 }

initial_datetime = Time.at(timestamp).utc.to_datetime
final_datetime = initial_datetime.next_year(durYears)
final_datetime = final_datetime.next_month(durMonths)
final_datetime = final_datetime.next_day((7*durWeeks) + durDays)
final_timestamp = final_datetime.to_time.utc.to_i + (durHours * 3600) + (durMinutes * 60) + durSeconds
return final_timestamp
matches[2..8].map do |match|
if match
match = match.tr(',', '.').gsub(/\.0*\z/, '')
sign * (match.include?('.') ? match.to_f : match.to_i)
else
0
end
end

datetime = Time.at(timestamp).utc.to_datetime
datetime = datetime.next_year(durYears)
datetime = datetime.next_month(durMonths)
datetime = datetime.next_day((7*durWeeks) + durDays)
datetime.to_time.utc.to_i + (durHours * 3600) + (durMinutes * 60) + durSeconds
end

# Return a properly formatted x509 certificate
Expand Down
Loading

0 comments on commit 99ec80d

Please sign in to comment.