 e36d7928e4
			
		
	
	e36d7928e4
	
	
	
		
			
			add New fields for - assertion_valid_not_before - assertion_valid_not_on_or_after - session_valid_not_on_or_after allow flexible time durations for these fields fall back to Provider's ACS if none is specified in AuthNRequest
		
			
				
	
	
		
			31 lines
		
	
	
		
			846 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			846 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| """Test time utils"""
 | |
| from datetime import timedelta
 | |
| 
 | |
| from django.core.exceptions import ValidationError
 | |
| from django.test import TestCase
 | |
| 
 | |
| from passbook.providers.saml.utils.time import (
 | |
|     timedelta_from_string,
 | |
|     timedelta_string_validator,
 | |
| )
 | |
| 
 | |
| 
 | |
| class TestTimeUtils(TestCase):
 | |
|     """Test time-utils"""
 | |
| 
 | |
|     def test_valid(self):
 | |
|         """Test valid expression"""
 | |
|         expr = "hours=3;minutes=1"
 | |
|         expected = timedelta(hours=3, minutes=1)
 | |
|         self.assertEqual(timedelta_from_string(expr), expected)
 | |
| 
 | |
|     def test_invalid(self):
 | |
|         """Test invalid expression"""
 | |
|         with self.assertRaises(ValueError):
 | |
|             timedelta_from_string("foo")
 | |
| 
 | |
|     def test_validation(self):
 | |
|         """Test Django model field validator"""
 | |
|         with self.assertRaises(ValidationError):
 | |
|             timedelta_string_validator("foo")
 |