def test_renew_delegation_token(self): kerb_auth = Mock() with patch('desktop.lib.raz.raz_client.requests.get') as requests_get: with patch('desktop.lib.raz.raz_client.socket.gethostbyname' ) as gethostbyname: requests_get.return_value = Mock( text='{"Token":{"urlString":"https://gethue-test.s3.amazonaws.com/gethue/data/customer.csv?' + \ 'AWSAccessKeyId=AKIA23E77ZX2HVY76YGL' + \ '&Signature=3lhK%2BwtQ9Q2u5VDIqb4MEpoY3X4%3D&Expires=1617207304"}}' ) gethostbyname.return_value = '128.0.0.1' token = RazToken(raz_url='https://raz.gethue.com:8080', auth_handler=kerb_auth) t = token.renew_delegation_token(user=self.username) assert_equal( t, 'https://gethue-test.s3.amazonaws.com/gethue/data/customer.csv?AWSAccessKeyId=AKIA23E77ZX2HVY76YGL&' 'Signature=3lhK%2BwtQ9Q2u5VDIqb4MEpoY3X4%3D&Expires=1617207304' ) with patch('desktop.lib.raz.raz_client.requests.put' ) as requests_put: token.init_time += timedelta(hours=9) t = token.renew_delegation_token(user=self.username) requests_put.assert_called()
def test_create(self): kerb_auth = Mock() token = RazToken(raz_url='https://raz.gethue.com:8080', auth_handler=kerb_auth) assert_equal('raz.gethue.com', token.raz_hostname) assert_equal('8080', token.raz_port) assert_equal('https', token.scheme)