yan12125 opened a new issue #1490:
URL: https://github.com/apache/libcloud/issues/1490


   ## Summary
   
   In `test_v4_signature_contains_credential_scope`, date in URL may not match 
the expected one if the time zone != UTC.
   
   ## Detailed Information
   
   For example, I'm running on a machine with time zone CST (UTC+8). The 
aforementioned test fails
   ```
   _ 
OSCRequestSignerAlgorithmV4TestCase.test_v4_signature_contains_credential_scope 
_
    
   self = <libcloud.test.common.test_osc.OSCRequestSignerAlgorithmV4TestCase 
testMethod=test_v4_signature_contains_credential_scope>
    
       def test_v4_signature_contains_credential_scope(self):
           action = "ReadImages"
           headers = self.signer.get_request_headers(
               action=action,
               data="{}",
               service_name=self.driver.service_name,
               region=self.driver.region
           )
   >       self.assertIn(
               'Credential=my_key/{}/my_region/my_service/osc4_request'.format(
                   datetime.now().strftime('%Y%m%d')
               ),
               headers["Authorization"]
           )
   E       AssertionError: 
'Credential=my_key/20200921/my_region/my_service/osc4_request' not found in 
'OSC4-HMAC-SHA256 Credential=my_key/20200920/my_region/my_service/osc4_request, 
SignedHeaders=content-type;host;x-osc-date, 
Signature=d0b6d1d916011b61a9963a0a61000a0e46253ab85b452596116ac410ed671561'
    
   libcloud/test/common/test_osc.py:58: AssertionError
   ```
   
   The build starts at 21 Sep 02:15:39 AM CST. The date is 20200921 in local 
time zone and 20200920 in UTC. Looks like the issue is that the test uses local 
time zone [1] while the code uses UTC [2]
   
   [1] 
https://github.com/apache/libcloud/blob/1000049bb9955a071c78cb5f6f85ad6f4b780931/libcloud/test/common/test_osc.py#L60
   [2] 
https://github.com/apache/libcloud/blob/1000049bb9955a071c78cb5f6f85ad6f4b780931/libcloud/common/osc.py#L77
   
   Environment: Arch Linux, Python 3.8, apache-libcloud 3.2.0


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to