1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 '* Copyright 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: security_certified_docs.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:15 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* owner : joerg.skottke@sun.co
36 '* short description : Load certified documents and verify the certificate
38 '\******************************************************************************
40 testcase tLoadCertifiedFile( cBuildID as string )
42 '///<H1>Load certified documents and verify the certificate</H1>
43 '///This test loads a document which has been signed with a digital
44 '///signature (dummy certificate) and verifies, that the certificate
45 '///remains with the document through looking at the "digital signatures"
49 ' Build the path to the file we want to work with
51 cFile = gTesttoolpath & "framework\optional\input\security\DigitalSignature"
52 cFile = cFile & hGetSuffix( cBuildId )
53 cFile = convertpath( cFile )
54 printlog( "Using file: " & cFile )
56 dim cSigName as string
57 dim sCertData( 20 ) as string
60 sFileIn = gTesttoolPath & "framework\optional\input\security\certificate_data.txt"
61 sFileIn = convertpath( sFileIn )
63 dim sFileOut as string
64 sFileOut = hGetWorkPath() & "certificate_data.txt"
66 ' Variable to store boolean returncodes from functions
70 ' the number of certificates attached to the current document
71 dim iCertCount as integer
73 '///<li>Load a file that has been signed with a certificate</li>
74 printlog( "Load the file" )
75 brc = hFileOpen( cFile )
76 brc = hHandleActivesOnLoad( 0 , 2 )
78 ' in case the file did not get loaded, handle the problem by aborting the test
80 warnlog( "The requested file could not be loaded, aborting test" )
84 brc = hOpenDigitalSignaturesDialog()
86 ' If the menuitem should not be available, clicking it will fail. In
87 ' this case we must assume that the file has been loaded but the certificate
88 ' does not exist. So we close the document and abort the test here.
90 warnlog( "The requested menuitem is not available, the test ends" )
95 ' second line of defense: If something was opened but this is not the
96 ' digital signatures dialog, we abort as well.
97 ' If no mozill a profile exists, we don't have the means to verify
98 ' certificates, so the test aborts here as well. We get a messagebox then.
99 Kontext "DigitalSignature"
100 if ( not DigitalSignature.exists( 2 ) ) then
102 if ( active.exists() ) then
103 qaerrorlog( "#i48252# Mozilla profile missing?: " & active.getText() )
106 warnlog( "The current dialog is not <Digital Signatures>. Aborting" )
108 call hCloseDocument()
112 '///<li>Verify that exactly one certificate exists</li>
113 ' If we have zero or more than one certificate, this is probably a bug
114 ' introduced by the test maintainer. However, we warn but the test can
116 Kontext "DigitalSignature"
118 '///+<li>Click on "View Certificate"</li>
119 ViewCertificate.click()
121 '///+<li>Switch to the "Certification Path"</li>
122 hSelectXMLSecTab( "PATH" )
124 qaerrorlog( "Skipping EditBrowseBox: Not implemented in Testtool yet" )
125 goto SkipEditBrowseBox
127 '///+<li>Read the name of the certificate from the treelist, verify</li>
128 kontext "TabXMLSecCertPath"
129 XMLSecViewSigTree.select( 1 )
130 cSigName = XMLSecViewSigTree.getSelText()
131 if ( cSigName <> "Dummy Certificate for Testing" ) then
132 warnlog( "The certificate at pos. 1 is not the dummy certificate: " & cSigName )
134 printlog( "Found correct certificate name: " & cSigName )
137 '///+<li>Switch to the second tabpage (Details)</li>
138 hSelectXMLSecTab( "DETAILS" )
140 kontext "TabXMLSecDetails"
141 hGetListItems( XMLSecDetailsListBox, sCertData() )
143 '///+<li>Verify that the data in the listbox is correct (reference file)</li>
144 brc = hManageComparisionList( sFileIn, sFileOut, sCertData() )
146 warnlog( "The data of the certificate appears to be incorrect" )
148 printlog( "Verification of the certificate succeeded" )
153 '///+<li>Switch to the first page (General)</li>
154 hSelectXMLSecTab( "GENERAL" )
155 kontext "TabXMLSecGeneral"
157 '///+<li>Close the dialog with OK</li>
158 TabXMLSecGeneral.ok()
160 '///<li>Close the certication dialog with OK</li>
161 printlog( "Close the dialog with OK" )
162 Kontext "DigitalSignature"
163 DigitalSignature.OK()
165 '///<li>Close the document</li>
166 printlog( "Close the document" )
167 call hCloseDocument()