|
| 1 | +# encoding=utf-8 |
| 2 | +# !/usr/bin/env python |
| 3 | +# |
| 4 | +# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved. |
| 5 | +# |
| 6 | + |
| 7 | +from snowflake.connector.ocsp_snowflake import OCSPCache |
| 8 | + |
| 9 | + |
| 10 | +def test_building_retry_url(): |
| 11 | + # privatelink retry url |
| 12 | + OCSPCache.ACTIVATE_SSD = False |
| 13 | + OCSPCache.RETRY_URL_PATTERN = None |
| 14 | + OCSPCache.CACHE_SERVER_URL = \ |
| 15 | + 'http://ocsp.us-east-1.snowflakecomputing.com/ocsp_response_cache.json' |
| 16 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 17 | + assert OCSPCache.RETRY_URL_PATTERN == \ |
| 18 | + 'http://ocsp.us-east-1.snowflakecomputing.com/retry/{0}/{1}' |
| 19 | + |
| 20 | + # privatelink retry url with port |
| 21 | + OCSPCache.ACTIVATE_SSD = False |
| 22 | + OCSPCache.RETRY_URL_PATTERN = None |
| 23 | + OCSPCache.CACHE_SERVER_URL = \ |
| 24 | + 'http://ocsp.us-east-1.snowflakecomputing.com:80/ocsp_response_cache' \ |
| 25 | + '.json' |
| 26 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 27 | + assert OCSPCache.RETRY_URL_PATTERN == \ |
| 28 | + 'http://ocsp.us-east-1.snowflakecomputing.com:80/retry/{0}/{1}' |
| 29 | + |
| 30 | + # non-privatelink retry url |
| 31 | + OCSPCache.ACTIVATE_SSD = False |
| 32 | + OCSPCache.RETRY_URL_PATTERN = None |
| 33 | + OCSPCache.CACHE_SERVER_URL = \ |
| 34 | + 'http://ocsp.snowflakecomputing.com/ocsp_response_cache.json' |
| 35 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 36 | + assert OCSPCache.RETRY_URL_PATTERN is None |
| 37 | + |
| 38 | + # non-privatelink retry url with port |
| 39 | + OCSPCache.ACTIVATE_SSD = False |
| 40 | + OCSPCache.RETRY_URL_PATTERN = None |
| 41 | + OCSPCache.CACHE_SERVER_URL = \ |
| 42 | + 'http://ocsp.snowflakecomputing.com:80/ocsp_response_cache.json' |
| 43 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 44 | + assert OCSPCache.RETRY_URL_PATTERN is None |
| 45 | + |
| 46 | + # ssd enabled for privatelink retry url |
| 47 | + OCSPCache.ACTIVATE_SSD = True |
| 48 | + OCSPCache.RETRY_URL_PATTERN = None |
| 49 | + OCSPCache.CACHE_SERVER_URL = \ |
| 50 | + 'http://ocsp.us-east-1.snowflakecomputing.com/ocsp_response_cache.json' |
| 51 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 52 | + assert OCSPCache.RETRY_URL_PATTERN == \ |
| 53 | + 'http://ocsp.us-east-1.snowflakecomputing.com/retry' |
| 54 | + |
| 55 | + # ssd enabled for privatelink retry url with port |
| 56 | + OCSPCache.ACTIVATE_SSD = True |
| 57 | + OCSPCache.RETRY_URL_PATTERN = None |
| 58 | + OCSPCache.CACHE_SERVER_URL = \ |
| 59 | + 'http://ocsp.us-east-1.snowflakecomputing.com:80/ocsp_response_cache' \ |
| 60 | + '.json' |
| 61 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 62 | + assert OCSPCache.RETRY_URL_PATTERN == \ |
| 63 | + 'http://ocsp.us-east-1.snowflakecomputing.com:80/retry' |
| 64 | + |
| 65 | + # ssd enabled for non-privatelink |
| 66 | + OCSPCache.ACTIVATE_SSD = True |
| 67 | + OCSPCache.RETRY_URL_PATTERN = None |
| 68 | + OCSPCache.CACHE_SERVER_URL = \ |
| 69 | + 'http://ocsp.snowflakecomputing.com/ocsp_response_cache.json' |
| 70 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 71 | + assert OCSPCache.RETRY_URL_PATTERN == \ |
| 72 | + 'http://ocsp.snowflakecomputing.com/retry' |
| 73 | + |
| 74 | + # ssd enabled for non-privatelink with port |
| 75 | + OCSPCache.ACTIVATE_SSD = True |
| 76 | + OCSPCache.RETRY_URL_PATTERN = None |
| 77 | + OCSPCache.CACHE_SERVER_URL = \ |
| 78 | + 'http://ocsp.snowflakecomputing.com:80/ocsp_response_cache.json' |
| 79 | + OCSPCache._reset_ocsp_dynamic_cache_server_url() |
| 80 | + assert OCSPCache.RETRY_URL_PATTERN == \ |
| 81 | + 'http://ocsp.snowflakecomputing.com/retry' |
0 commit comments