Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4477 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'       Release Manager Admin Tests
5
'       Designed to be called via AJAX and to return
6
'       JSON formatted data to dynamic page
7
'=====================================================
8
%>
9
<%
10
Option explicit
11
' Good idea to set when using redirect
12
Response.Expires = 0   ' always load the page, dont store
5168 dpurdie 13
Response.ContentType="application/json"
4477 dpurdie 14
%>
15
<!--#include file="common/conf.asp"-->
16
<!--#include file="common/globals.asp"-->
17
<!--#include file="common/qstr.asp"-->
18
<!--#include file="common/common_subs.asp"-->
19
<!--#include file="common/formating.asp"-->
5097 dpurdie 20
<!--#include file="common/release_changed.asp"-->
4477 dpurdie 21
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="common/base64encode.vbs"></SCRIPT> 
22
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT> 
23
<%
24
'------------ Variable Definition -------------
25
Dim parOpr, newitem
26
Dim result
27
 
28
' Basic Parameters
29
parOpr = QStrPar("Opr")
30
result = -1
31
 
32
' Init the output JSON class
33
'   Operations can add data
34
'   Default data will be added at the end
35
Dim oJSON
36
Set oJSON = New aspJSON
37
 
38
'
39
'   Determine the operation to be performed
4482 dpurdie 40
'   Invoke target routine
41
'   Expect:
42
'       result                    - test result
43
'       oJSON.data("emsgSummary") - Error detail
4477 dpurdie 44
'
4482 dpurdie 45
'
4477 dpurdie 46
If (parOpr = "zipTest") Then
4482 dpurdie 47
    Call zipFile
48
ElseIf (parOpr = "eventTest") Then
49
    Call sendEvent
50
ElseIf (parOpr = "emailTest") Then
51
    Call sendEmail
5172 dpurdie 52
ElseIf (parOpr = "reportEvent") Then
53
    Call reportEvent
4482 dpurdie 54
ElseIf (parOpr = "remExecTest") Then
5172 dpurdie 55
    Call remExecTest
4482 dpurdie 56
ElseIf (parOpr = "pkgAccessTest") Then
5172 dpurdie 57
    Call pkgAccessTest
5097 dpurdie 58
 
4482 dpurdie 59
Else
60
    oJSON.data("emsgSummary") = "Unknown operation requested:" & parOpr
61
End If
4477 dpurdie 62
 
4482 dpurdie 63
'
64
'   Create JSON data for the user
65
'   Important fields
66
'       result
67
'
68
'   Debug fields
69
'       Request (Array)
70
'
71
'Write single value
72
oJSON.data("result") = result
73
 
74
' DEBUG: An array of the user provided requests
75
Set oJSON.data("Request") = oJSON.Collection()
76
Set newitem = oJSON.AddToCollection(oJSON.data("Request"))
77
Dim variableName
78
for each variableName in Request.QueryString
79
    newitem.add variableName, Request.QueryString(variableName)
80
next
81
 
82
'Return the object
83
Response.Write oJSON.JSONoutput()
84
 
85
'-------------------------------------------------
86
' Function:    zipFile
87
' Description: Test the File Zipping process
88
Sub zipFile
4477 dpurdie 89
    '
90
    ' Create a test file in a known directory
91
    '
92
    Dim objZIPObject, ZipFile
93
    Dim outFile, objFSO, LocalDir, objFile
94
    Set objFSO=CreateObject("Scripting.FileSystemObject")
95
    LocalDir = Request.ServerVariables("APPL_PHYSICAL_PATH") & "release_manager\temp\"
96
 
97
    If NOT objFSO.FolderExists( LocalDir ) Then
98
        result = 1
99
        oJSON.data("emsgSummary") = "Folder not found:" & LocalDir
100
    Else
101
        ' Create a known file to zip up
102
        '
103
        outFile = LocalDir & "zipTestFile.txt"
104
        Set objFile = objFSO.CreateTextFile(outFile,True)
105
        objFile.Write "test string" & vbCrLf
106
        objFile.Close
107
 
108
        ' Zip up a test file
109
        '
110
        ZipFile = LocalDir & "zipTest.zip"
111
        If objFSO.FileExists(ZipFile) Then
112
       	    objFSO.DeleteFile ZipFile, TRUE
113
        End If
114
 
115
        On Error Resume Next
116
    	Set objZIPObject = Server.CreateObject("XStandard.Zip")
117
        If Err.Number <> 0 then
118
            result = 1
119
            oJSON.data("emsgSummary") = "Create XStandard.Zip:" & Err.Description
120
        Else
121
            objZIPObject.Pack outFile, ZipFile
122
 
123
            If objZIPObject.ErrorCode <> 0 then
124
                    result = 1
125
                    oJSON.data("emsgSummary") = "Zip Error XStandard:" & objZIPObject.ErrorCode & ":" & objZIPObject.ErrorDescription
126
            Else
127
                ' All done - must have passed
128
                result = 0
129
 
130
            End If
131
        End If
132
 
133
        '
134
        ' Clean up
135
        If objFSO.FileExists(outFile) Then
136
       	    objFSO.DeleteFile outFile, TRUE
137
        End If
138
 
139
        If objFSO.FileExists(ZipFile) Then
140
       	    objFSO.DeleteFile ZipFile, TRUE
141
        End If
142
 
143
        objZIPObject = Nothing
144
 
145
    End If
146
    set objFSO = Nothing
4482 dpurdie 147
End Sub
4477 dpurdie 148
 
4482 dpurdie 149
'-------------------------------------------------
5168 dpurdie 150
' Function:    reportEvent
151
' Description:  Create an event in the machines event log
152
 
153
Sub reportEvent
154
    Report_Event enumEVENT_ERROR, "Admin Test", "", "Release Manager test: reportEvent" 
155
    If Err.number = 0 Then
156
        result = 0
157
    Else
158
        result = 1
159
        oJSON.data("emsgSummary") = "Error:("&Err.number&"):" & Err.description
160
    End If
161
End Sub
162
 
163
'-------------------------------------------------
4482 dpurdie 164
' Function:    sendEvent
165
' Description: Send an Event to the Windows Log
166
Sub sendEvent
5168 dpurdie 167
    Send_Event enumEVENT_ERROR, "Release Manager Test Log" 
168
    If Err.number = 0 Then
169
        result = 0
170
    Else
171
        result = 1
172
        oJSON.data("emsgSummary") = "Error:("&Err.number&"):" & err.description
173
    End If
174
End Sub
175
 
176
'-------------------------------------------------
4482 dpurdie 177
' Function:     sendEmail
178
' Description:  Send an email
179
Sub sendEmail
180
   Dim Mode, Attachment, Message
181
 
182
   Attachment = Null
183
   Message = "This is a Test Email generated by the Release Manager Test."
184
   Mode = QStrPar("Mode")
185
 
186
   If Mode = "Attach" Then
187
        Attachment = Server.MapPath("images\img_reports_admin.jpg")
188
        Message = Message & " This message should have an attachment"
189
   End If
190
 
191
    Call Send_Email ( "Release Manager Notification", _
192
                       adminEmail, _
193
                       objAccessControl.UserEmail, _
194
                       "Test Email", _
195
                       Message, _
196
                       Attachment )
197
    result = Err.Number
198
    oJSON.data("emsgSummary") = Err.Description
199
    'oJSON.data("Info1") = Mode
200
    'oJSON.data("Info2") = Attachment
201
End Sub
202
 
203
'-------------------------------------------------
5172 dpurdie 204
' Function:    remExecTest
205
' Description: Ensure that we can communicate with the package server
206
 
207
Sub remExecTest
4482 dpurdie 208
 
5172 dpurdie 209
    Dim objRC: Set objRC = New ReleaseChanged
210
    Dim rv
4482 dpurdie 211
 
5172 dpurdie 212
    Call objRC.TestAccess(request.servervariables("server_name"))
213
    rv = objRc.last_resultCode
4482 dpurdie 214
    If rv = 0 Then
215
        result = 0
216
    Else
217
        result = 1
5172 dpurdie 218
        oJSON.data("emsgSummary") = "Error:("&rv&"), " & objRc.last_errorMsg
4482 dpurdie 219
    End If
5172 dpurdie 220
    Set objRC = Nothing
4482 dpurdie 221
End Sub
222
 
223
'-------------------------------------------------
5172 dpurdie 224
' Function:    pkgAccessTest
4482 dpurdie 225
' Description: Test dpkg_archive access - can we map it
4477 dpurdie 226
'
5172 dpurdie 227
Sub pkgAccessTest
4477 dpurdie 228
 
5172 dpurdie 229
    If testArchiveAccessPkg("","") Then
4482 dpurdie 230
        result = 0
231
    Else
232
        result = 1
5172 dpurdie 233
        oJSON.data("emsgSummary") = "Archive not responding"
4482 dpurdie 234
    End If
235
End Sub
4477 dpurdie 236
 
237
%>