@@ -441,7 +441,7 @@ def result(duration, reference = 0)
441441 end
442442 end
443443
444- describe 'time argument specified' do
444+ describe 'time argument specified as Time ' do
445445 let ( :now ) { Time . at ( 10000 ) }
446446
447447 it 'returns true for expired certificate' do
@@ -474,6 +474,20 @@ def result(duration, reference = 0)
474474 refute RubySaml ::Utils . is_cert_expired ( valid_cert_string , now )
475475 end
476476 end
477+
478+ describe 'time argument specified as Integer' do
479+ let ( :int ) { 10000 }
480+
481+ it 'returns true for expired certificate' do
482+ expired_cert = CertificateHelper . generate_cert ( not_after : Time . at ( int ) - 60 )
483+ assert RubySaml ::Utils . is_cert_expired ( expired_cert , int )
484+ end
485+
486+ it 'returns false for not-started certificate' do
487+ not_started_cert = CertificateHelper . generate_cert ( not_before : Time . at ( int ) + 60 )
488+ refute RubySaml ::Utils . is_cert_active ( not_started_cert , int )
489+ end
490+ end
477491 end
478492
479493 describe '.is_cert_active' do
@@ -510,7 +524,7 @@ def result(duration, reference = 0)
510524 end
511525 end
512526
513- describe 'time argument specified' do
527+ describe 'time argument specified as Time ' do
514528 let ( :now ) { Time . at ( 10000 ) }
515529
516530 it 'returns true for active certificate' do
@@ -543,5 +557,19 @@ def result(duration, reference = 0)
543557 refute RubySaml ::Utils . is_cert_active ( expired_cert_string , now )
544558 end
545559 end
560+
561+ describe 'time argument specified as Integer' do
562+ let ( :int ) { 10000 }
563+
564+ it 'returns true for active certificate' do
565+ valid_cert = CertificateHelper . generate_cert ( not_before : Time . at ( int ) - 60 , not_after : Time . at ( int ) + 60 )
566+ assert RubySaml ::Utils . is_cert_active ( valid_cert , int )
567+ end
568+
569+ it 'returns false for expired certificate' do
570+ expired_cert = CertificateHelper . generate_cert ( not_after : Time . at ( int ) - 60 )
571+ refute RubySaml ::Utils . is_cert_active ( expired_cert , int )
572+ end
573+ end
546574 end
547575end
0 commit comments