azure-quantum-python icon indicating copy to clipboard operation
azure-quantum-python copied to clipboard

Ability to enable and disable scrubbing of specific patterns in the test recordings

Open vxfield opened this issue 10 months ago • 0 comments

This PR adds the ability to enable and disable scrubbing of specific patterns in the test recordings.

Motivation

Disable the scrubbing of Storage Account SAS Key Expiration parameter se=, so it can be recorded and we can add automated test of automatic refresh of the SAS Key. We don't want to disable this scrubbing for all tests because then it would make all test recordings "expire" and fail as the SAS keys expire.

How to use it

  1. Import the RegexScrubbingPatterns class from the test's common namespace.
    from common import RegexScrubbingPatterns
    
  2. Wrap the part of the code you want to temporarily disable a particular scrubbing rule
    self.disable_scrubbing(RegexScrubbingPatterns.URL_QUERY_SAS_KEY_EXPIRATION)
    try:
       # your testing logic here that relies on the un-scrubbed value
    finally:
       self.enable_scrubbing(RegexScrubbingPatterns.URL_QUERY_SAS_KEY_EXPIRATION)
    

vxfield avatar Mar 28 '24 17:03 vxfield