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

Dry up signing roundtrip tests #198

Merged
5 commits merged into from
Feb 14, 2020
Merged

Dry up signing roundtrip tests #198

5 commits merged into from
Feb 14, 2020

Conversation

ghost
Copy link

@ghost ghost commented Feb 5, 2020

Closes #189. We had two helper functions that did basically the same. Dried those up.

@ghost ghost self-requested a review February 5, 2020 09:58
@ghost ghost self-assigned this Feb 5, 2020
@JOSESwiftCI
Copy link

1 Message
📖 Any non-trivial changes to code should be reflected in the changelog. Please consider adding a note in the Unreleased section of the CHANGELOG.md.

Generated by 🚫 Danger

Copy link
Contributor

@Jonathan-Airside Jonathan-Airside left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ Much more readable! Nice improvement!

@Jonathan-Airside Jonathan-Airside requested a review from a team February 6, 2020 14:55
ghost
ghost previously approved these changes Feb 7, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, a few tiny improvement suggestions if you're motivated.

Comment on lines 132 to 133
let algKidHeader = "{\"alg\":\"\(algorithm.rawValue)\",\"kid\":\"kid\"}"
let kidAlgHeader = "{\"kid\":\"kid\",\"alg\":\"\(algorithm.rawValue)\"}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could make these string literals a little cleaner to read by using extended string delimiters. Your call whether it's worth the trade off for noisier string interpolation.

Something like

let algKidHeader = #"{"alg":"\#(algorithm.rawValue)","kid":"kid"}"#

Copy link
Author

@ghost ghost Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 👍 But since we have lots and lots of such strings throughout the project, I tracked #202.

@@ -149,7 +128,19 @@ class JWSRSATests: RSACryptoTestCase {
let verifier = Verifier(verifyingAlgorithm: algorithm, publicKey: publicKeyAlice2048!)

XCTAssertTrue(secondJWS.isValid(for: verifier!))
XCTAssertEqual(String(data: jws.header.data(), encoding: .utf8), "{\"alg\":\"\(algorithm.rawValue)\"}")
if withKid {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement wants to be a guard. If you move the check from line 144 up above the branch then an early return wouldn't matter, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated ✅

@ghost ghost dismissed stale reviews from Jonathan-Airside and themself via c549b43 February 10, 2020 09:47
@ghost
Copy link
Author

ghost commented Feb 10, 2020

@nathan-mohemian Please re-review!

(I also ran code_format that's why there are some unrelated formatting changes in there now, sorry about that.)

@sonarcloud
Copy link

sonarcloud bot commented Feb 10, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Feb 13, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 19 Code Smells

92.0% 92.0% Coverage
3.0% 3.0% Duplication

@ghost ghost merged commit 4c4718d into master Feb 14, 2020
@ghost ghost deleted the fix-jws-tests branch February 14, 2020 10:18
ghost pushed a commit that referenced this pull request Feb 14, 2020
* Rename asymmetric algorithm

* Rename symmetric algorithm

* Refactor algorithm enums

* Sketch out new encryption flow

* Refactor encryption flow

* Fix reference to old rsa encrypter

* Remove dummy keywrap mode

* Fix and extendcompression tests

* Add key management mode tests

* Adapt rsa tests

* Add alg check test

* Disable space linter rule for now

* Adap AES tests

* Add license headers to new files

* Make sonarqube happy

* Do full Sonarqube analysis in pull requests (#201)

* Do sonarqube analysis after test

* Log fastlane contents

* Remove deletion of coverage report

* Update sonar config to point to sonarcloud

* Trigger analysis

* Exclude tests from duplication calculation

* Remove loggign

* Dry up signing roundtrip tests (#198)

* Dry up tests

* Use guard in test helper

* Format code

* Redo mode creation

* REname key encryption mode implementations

* Final cleanup

* Commit something

* Revert "Commit something"

This reverts commit 91266d4.
ghost pushed a commit that referenced this pull request Feb 17, 2020
* Restructure JWE encryption flow (#203)

* Rename asymmetric algorithm

* Rename symmetric algorithm

* Refactor algorithm enums

* Sketch out new encryption flow

* Refactor encryption flow

* Fix reference to old rsa encrypter

* Remove dummy keywrap mode

* Fix and extendcompression tests

* Add key management mode tests

* Adapt rsa tests

* Add alg check test

* Disable space linter rule for now

* Adap AES tests

* Add license headers to new files

* Make sonarqube happy

* Do full Sonarqube analysis in pull requests (#201)

* Do sonarqube analysis after test

* Log fastlane contents

* Remove deletion of coverage report

* Update sonar config to point to sonarcloud

* Trigger analysis

* Exclude tests from duplication calculation

* Remove loggign

* Dry up signing roundtrip tests (#198)

* Dry up tests

* Use guard in test helper

* Format code

* Redo mode creation

* REname key encryption mode implementations

* Final cleanup

* Commit something

* Revert "Commit something"

This reverts commit 91266d4.

* Restructure JWE decryption flow (#208)

* Replicate encryption flow for decryption

* Fix tests

* Split rsa mode in two types

* Replace deprecated decrypter calls in tests

* Remove todos

* Add documentation

* Update alg documentation

* Fix typos

* Add key types to doc

* Change access modifiers back
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix performTestRSASign function
3 participants