techservicesillinois / clearpass-api

Client for Aruba Clearpass
Other
0 stars 0 forks source link

Add test_connectivity and VCRPY #2

Closed edthedev closed 5 months ago

edthedev commented 5 months ago

Context

Our primary use case is our SOAR app, which expects a test connectivity feature. It makes the most sense to provide that here, in this library.

Tasks

tzturner commented 5 months ago

We've reached the point where we need to scrub cassettes of credentials info. Next step is to implement a VCR cleaner.

Yesterday, two .yaml files were checked in containing ClearPass credentials. We informed security@illinois.edu, set the repo to private, and deleted the two .yaml files in question.

tzturner commented 5 months ago

Cleaner is partially implemented. We are having trouble cleaning the token from the response.

It appears that in our cassette method in conftest.py, our serializer (cleanyaml') is not being used, despite being registered as a cleaner. Instead, the serializeryaml` is being used.

yaml_cleaner = CleanYAMLSerializer()
    my_vcr.register_serializer("cleanyaml", yaml_cleaner)
    # TODO: Register cleaner functions here:
    yaml_cleaner.register_cleaner(clean_auth)

    breakpoint()
    with my_vcr.use_cassette(f'{request.function.__name__}.yaml',
                             seralizer='cleanyaml') as tape:
(Pdb) my_vcr.serializers
{'yaml': <module 'vcr.serializers.yamlserializer' from '/home/tzturner/projects/clearpass-api/venv/lib64/python3.9/site-packages/vcr/serializers/yamlserializer.py'>,
'json': <module 'vcr.serializers.jsonserializer' from '/home/tzturner/projects/clearpass-api/venv/lib64/python3.9/site-packages/vcr/serializers/jsonserializer.py'>,
'cleanyaml': <vcr_cleaner.CleanYAMLSerializer object at 0x7fa012124160>}
(Pdb) my_vcr.serializer
'yaml'
tzturner commented 5 months ago

The problem above was due to a spelling error. serializer is not spelled seralizer.