Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
38639391
Commit
38639391
authored
Sep 26, 2006
by
Paul Vriens
Committed by
Alexandre Julliard
Sep 26, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Add tests for CryptSIPRetrieveSubjectGuid.
parent
5dadca4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
167 additions
and
0 deletions
+167
-0
sip.c
dlls/crypt32/tests/sip.c
+167
-0
No files found.
dlls/crypt32/tests/sip.c
View file @
38639391
...
...
@@ -23,11 +23,25 @@
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <winnls.h>
#include <wincrypt.h>
#include <mssip.h>
#include "wine/test.h"
static
char
*
show_guid
(
const
GUID
*
guid
)
{
static
char
guidstring
[
39
];
sprintf
(
guidstring
,
"{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"
,
guid
->
Data1
,
guid
->
Data2
,
guid
->
Data3
,
guid
->
Data4
[
0
],
guid
->
Data4
[
1
],
guid
->
Data4
[
2
],
guid
->
Data4
[
3
],
guid
->
Data4
[
4
],
guid
->
Data4
[
5
],
guid
->
Data4
[
6
],
guid
->
Data4
[
7
]
);
return
guidstring
;
}
static
void
test_AddRemoveProvider
(
void
)
{
BOOL
ret
;
...
...
@@ -104,6 +118,158 @@ static void test_AddRemoveProvider(void)
GetLastError
());
}
static
void
test_SIPRetrieveSubjectGUID
(
void
)
{
BOOL
ret
;
GUID
subject
;
HANDLE
file
;
static
const
CHAR
windir
[]
=
"windir"
;
static
const
CHAR
regeditExe
[]
=
"regedit.exe"
;
static
const
GUID
nullSubject
=
{
0x0
,
0x0
,
0x0
,
{
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
,
0x0
}};
static
const
WCHAR
deadbeef
[]
=
{
'c'
,
':'
,
'\\'
,
'd'
,
'e'
,
'a'
,
'd'
,
'b'
,
'e'
,
'e'
,
'f'
,
'.'
,
'd'
,
'b'
,
'f'
,
0
};
/* Couldn't find a name for this GUID, it's the one used for 95% of the files */
static
const
GUID
unknownGUID
=
{
0xC689AAB8
,
0x8E78
,
0x11D0
,
{
0x8C
,
0x47
,
0x00
,
0xC0
,
0x4F
,
0xC2
,
0x95
,
0xEE
}};
static
CHAR
regeditPath
[
MAX_PATH
];
static
WCHAR
regeditPathW
[
MAX_PATH
];
static
CHAR
path
[
MAX_PATH
];
static
CHAR
tempfile
[
MAX_PATH
];
static
WCHAR
tempfileW
[
MAX_PATH
];
DWORD
written
;
/* NULL check */
SetLastError
(
0xdeadbeef
);
ret
=
CryptSIPRetrieveSubjectGuid
(
NULL
,
NULL
,
NULL
);
ok
(
!
ret
,
"Expected CryptSIPRetrieveSubjectGuid to fail
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %ld.
\n
"
,
GetLastError
());
/* Test with a non-existent file (hopefully) */
SetLastError
(
0xdeadbeef
);
/* Set subject to something other than zero's */
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
deadbeef
,
NULL
,
&
subject
);
ok
(
!
ret
,
"Expected CryptSIPRetrieveSubjectGuid to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND, got %ld.
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
nullSubject
,
sizeof
(
GUID
)),
"Expected a NULL GUID for c:
\\
deadbeef.dbf, not %s
\n
"
,
show_guid
(
&
subject
));
}
/* Now with an executable that should exist
*
* Use A-functions where possible as that should be available on all platforms
*/
GetEnvironmentVariableA
(
windir
,
regeditPath
,
MAX_PATH
);
sprintf
(
regeditPath
,
"%s
\\
%s"
,
regeditPath
,
regeditExe
);
MultiByteToWideChar
(
CP_ACP
,
0
,
regeditPath
,
strlen
(
regeditPath
)
+
1
,
regeditPathW
,
sizeof
(
regeditPathW
)
/
sizeof
(
regeditPathW
[
0
])
);
SetLastError
(
0xdeadbeef
);
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
regeditPathW
,
NULL
,
&
subject
);
todo_wine
{
ok
(
ret
,
"Expected CryptSIPRetrieveSubjectGuid to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got 0x%08lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
unknownGUID
,
sizeof
(
GUID
)),
"Expected (%s), got (%s).
\n
"
,
show_guid
(
&
unknownGUID
),
show_guid
(
&
subject
));
}
/* The same thing but now with a handle instead of a filename */
file
=
CreateFileA
(
regeditPath
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
SetLastError
(
0xdeadbeef
);
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
NULL
,
file
,
&
subject
);
todo_wine
{
ok
(
ret
,
"Expected CryptSIPRetrieveSubjectGuid to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got 0x%08lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
unknownGUID
,
sizeof
(
GUID
)),
"Expected (%s), got (%s).
\n
"
,
show_guid
(
&
unknownGUID
),
show_guid
(
&
subject
));
}
CloseHandle
(
file
);
/* And both */
file
=
CreateFileA
(
regeditPath
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
SetLastError
(
0xdeadbeef
);
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
regeditPathW
,
file
,
&
subject
);
todo_wine
{
ok
(
ret
,
"Expected CryptSIPRetrieveSubjectGuid to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got 0x%08lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
unknownGUID
,
sizeof
(
GUID
)),
"Expected (%s), got (%s).
\n
"
,
show_guid
(
&
unknownGUID
),
show_guid
(
&
subject
));
}
CloseHandle
(
file
);
/* Now with an empty file */
GetTempPathA
(
sizeof
(
path
),
path
);
GetTempFileNameA
(
path
,
"sip"
,
0
,
tempfile
);
MultiByteToWideChar
(
CP_ACP
,
0
,
tempfile
,
strlen
(
tempfile
)
+
1
,
tempfileW
,
sizeof
(
tempfileW
)
/
sizeof
(
tempfileW
[
0
])
);
SetLastError
(
0xdeadbeef
);
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
tempfileW
,
NULL
,
&
subject
);
ok
(
!
ret
,
"Expected CryptSIPRetrieveSubjectGuid to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_FILE_INVALID
||
GetLastError
()
==
S_OK
/* Win98 */
,
"Expected ERROR_FILE_INVALID or S_OK, got 0x%08lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
nullSubject
,
sizeof
(
GUID
)),
"Expected a NULL GUID for empty file %s, not %s
\n
"
,
tempfile
,
show_guid
(
&
subject
));
}
/* Use a file with a size of 3 (at least < 4) */
file
=
CreateFileA
(
tempfile
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
WriteFile
(
file
,
"123"
,
3
,
&
written
,
NULL
);
CloseHandle
(
file
);
SetLastError
(
0xdeadbeef
);
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
tempfileW
,
NULL
,
&
subject
);
ok
(
!
ret
,
"Expected CryptSIPRetrieveSubjectGuid to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
S_OK
/* Win98 */
,
"Expected ERROR_INVALID_PARAMETER or S_OK, got 0x%08lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
nullSubject
,
sizeof
(
GUID
)),
"Expected a NULL GUID for empty file %s, not %s
\n
"
,
tempfile
,
show_guid
(
&
subject
));
}
/* And now >= 4 */
file
=
CreateFileA
(
tempfile
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
WriteFile
(
file
,
"1234"
,
4
,
&
written
,
NULL
);
CloseHandle
(
file
);
SetLastError
(
0xdeadbeef
);
memset
(
&
subject
,
1
,
sizeof
(
GUID
));
ret
=
CryptSIPRetrieveSubjectGuid
(
tempfileW
,
NULL
,
&
subject
);
ok
(
!
ret
,
"Expected CryptSIPRetrieveSubjectGuid to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
TRUST_E_SUBJECT_FORM_UNKNOWN
||
GetLastError
()
==
S_OK
/* Win98 */
,
"Expected TRUST_E_SUBJECT_FORM_UNKNOWN or S_OK, got 0x%08lx
\n
"
,
GetLastError
());
ok
(
!
memcmp
(
&
subject
,
&
nullSubject
,
sizeof
(
GUID
)),
"Expected a NULL GUID for empty file %s, not %s
\n
"
,
tempfile
,
show_guid
(
&
subject
));
}
/* Clean up */
DeleteFileA
(
tempfile
);
}
static
void
test_SIPLoad
(
void
)
{
BOOL
ret
;
...
...
@@ -182,5 +348,6 @@ static void test_SIPLoad(void)
START_TEST
(
sip
)
{
test_AddRemoveProvider
();
test_SIPRetrieveSubjectGUID
();
test_SIPLoad
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment