Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state to integration tests #147

Merged
merged 4 commits into from
Jul 23, 2024
Merged

Add state to integration tests #147

merged 4 commits into from
Jul 23, 2024

Conversation

AdamVe
Copy link
Member

@AdamVe AdamVe commented Jul 23, 2024

With the HW/FW being more advanced, we need to support different parameters for the integration tests - for example FIPS approved devices need to use different (complex) PINs, sessions need to be opened with specific SCP parameters and similar.

We kept such information in static variables (for example PivTestState.DEFAULT_MANAGEMENT_KEY) which were initialized by a static method (for example PivTestUtils.verifyAndSetup(device)). This approach is not scalable and this PR introduces a TestState class which holds the test related information and is passed into the testing methods.

The class has subclasses for each application (where applicable) which setup and verify the state based on the connected device.

The TestState class holds the following properties:

  • YubikeyDevice currentDevice - the device which the integration tests is using
  • ScpParameters scpParameters - SCP related data (keys, kid)
  • ReconnectDeviceCallback reconnectCallback - callback which will cause a reconnection of a device, provided by the platform (currently Android only) code
  • boolean isUsbTransport - helper to get the transport flag

The TestState class also provides helper for its sub classes which can be used to open connections and get different sessions.

The subclasses contain specific properties which can be used during a test session. These properties are initialized in the constructor. Currently there are following properties

  • PivTestState: isFipsApproved, defaultPin, defaultPuk, defaultManagementKey
  • OathTestState: isFipsApproved, password
  • OpenPgpTestState: isFipsApproved, defaultUserPin, defaultAdminPin
  • MpeTestState: none

The platform test framework can execute two types of tests: session specific or device specific. The device specific tests can be used to process information which is not part of the session and also run several session tests during one tests - after each test, the reconnect callback is used to artificially reconnect the device (see OathDeviceTests.changePassword which changes the OATH password in one session and verifies it directly in another).

As part of this PR also the following tests has been updated to use the TestState approach: MultiProtocolReset, PinComplexity and Oath.

To write new integration tests, the only difference is that they should have a second parameter holding the state.

@AdamVe AdamVe merged commit 9a7d87d into dain/scp Jul 23, 2024
1 check passed
@AdamVe AdamVe deleted the adamve/tests/test_state branch July 23, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant