-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for DP API protect/unprotect (#314)
- Loading branch information
Showing
12 changed files
with
162 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"Filed out from Dolphin Smalltalk 7"! | ||
|
||
DolphinTest subclass: #DpApiTest | ||
instanceVariableNames: '' | ||
classVariableNames: '' | ||
poolDictionaries: '' | ||
classInstanceVariableNames: ''! | ||
DpApiTest guid: (GUID fromString: '{9165806D-C1A3-45E6-BF08-54EA3A21B04C}')! | ||
DpApiTest comment: ''! | ||
!DpApiTest categoriesForClass!Unclassified! ! | ||
!DpApiTest methodsFor! | ||
|
||
testProtectUnprotectData | ||
#('' 'a' 'abc' #[] #[0] #[128 255 1]) do: [:each | self verifyRoundTrip: each]! | ||
|
||
verifyRoundTrip: aByteObject | ||
| entropy decrypted encryptedExtra encrypted | | ||
entropy := #[1 2 3 4]. | ||
encrypted := Crypt32Library protectData: aByteObject. | ||
encryptedExtra := Crypt32Library protectData: aByteObject additionalEntropy: entropy. | ||
decrypted := Crypt32Library unprotectData: encrypted. | ||
self assert: aByteObject equals: decrypted. | ||
"Unprotect with entropy not used on protect should fail." | ||
self | ||
should: [Crypt32Library unprotectData: encryptedExtra] | ||
raise: Win32Error | ||
matching: [:ex | ex tag statusCode = Win32Errors.ERROR_INVALID_DATA]. | ||
decrypted := Crypt32Library unprotectData: encryptedExtra additionalEntropy: entropy. | ||
self assert: aByteObject equals: decrypted. | ||
"Unprotect without entropy used on protect should fail." | ||
self | ||
should: [Crypt32Library unprotectData: encryptedExtra] | ||
raise: Win32Error | ||
matching: [:ex | ex tag statusCode = Win32Errors.ERROR_INVALID_DATA]. | ||
self | ||
should: [Crypt32Library unprotectData: encryptedExtra additionalEntropy: #[4 5 6]] | ||
raise: Win32Error | ||
matching: [:ex | ex tag statusCode = Win32Errors.ERROR_INVALID_DATA]! ! | ||
!DpApiTest categoriesFor: #testProtectUnprotectData!public!unit tests! ! | ||
!DpApiTest categoriesFor: #verifyRoundTrip:!helpers!private! ! | ||
|
39 changes: 39 additions & 0 deletions
39
Core/Object Arts/Dolphin/System/Win32/Windows Data Protection API Tests.pax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
| package | | ||
package := Package name: 'Windows Data Protection API Tests'. | ||
package paxVersion: 1; | ||
basicComment: ''. | ||
|
||
|
||
package classNames | ||
add: #DpApiTest; | ||
yourself. | ||
|
||
package binaryGlobalNames: (Set new | ||
yourself). | ||
|
||
package globalAliases: (Set new | ||
yourself). | ||
|
||
package setPrerequisites: (IdentitySet new | ||
add: '..\..\Base\Dolphin'; | ||
add: '..\..\Base\Dolphin Base Tests'; | ||
add: 'Windows Data Protection API'; | ||
yourself). | ||
|
||
package! | ||
|
||
"Class Definitions"! | ||
|
||
DolphinTest subclass: #DpApiTest | ||
instanceVariableNames: '' | ||
classVariableNames: '' | ||
poolDictionaries: '' | ||
classInstanceVariableNames: ''! | ||
|
||
"Global Aliases"! | ||
|
||
|
||
"Loose Methods"! | ||
|
||
"End of package definition"! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
param | ||
( | ||
[string]$VMversion="v7.0.38" | ||
[string]$VMversion="v7.0.39" | ||
) | ||
|
||
Try | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters