Yubico / Yubico.NET.SDK

A YubiKey SDK for .NET developers
Apache License 2.0
96 stars 48 forks source link

Make YubiKeyDeviceListener resettable #89

Open jamiehankins opened 1 month ago

jamiehankins commented 1 month ago

Currently, YubiKeyDeviceListener only exposes a singleton instance with no way for a consumer to reset it once it is started. The constructor is private, so the consumer has no option to use a private instance.

This adds the ability for the consumer to reset the lazy-initialized singleton so that the listen thread doesn't stick around.

Also, even though this class implemented IDisposable, most things that need to be in the Dispose method weren't there, including a way to stop the thread.

The listen thread is now replaced by an asynchronous task that doesn't consume a system thread while it's not working.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # YESDK-1313

Type of change

Please delete options that are not relevant.

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test configuration:

Checklist:

github-actions[bot] commented 1 month ago

Test Results: Windows

    2 files      2 suites   2s :stopwatch: 3 615 tests 3 615 :white_check_mark: 0 :zzz: 0 :x: 3 617 runs  3 617 :white_check_mark: 0 :zzz: 0 :x:

Results for commit ce5ddc13.

github-actions[bot] commented 1 month ago

Test Results: Ubuntu

    2 files      2 suites   5s :stopwatch: 3 607 tests 3 607 :white_check_mark: 0 :zzz: 0 :x: 3 609 runs  3 609 :white_check_mark: 0 :zzz: 0 :x:

Results for commit ce5ddc13.

github-actions[bot] commented 1 month ago

Test Results: MacOS

    2 files      2 suites   1s :stopwatch: 3 607 tests 3 607 :white_check_mark: 0 :zzz: 0 :x: 3 609 runs  3 609 :white_check_mark: 0 :zzz: 0 :x:

Results for commit ce5ddc13.

github-actions[bot] commented 1 month ago

Code Coverage

Package Line Rate Branch Rate Complexity Health
Yubico.Core 42% 32% 4245
Yubico.YubiKey 51% 47% 18438
Summary 49% (31665 / 64296) 45% (8014 / 17985) 22683

Minimum allowed line rate is 40%