~ubuntu-branches/ubuntu/lucid/libstruts1.2-java/lucid

« back to all changes in this revision

Viewing changes to web/test/test/org/apache/struts/taglib/html/TestPasswordTag2.jsp

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-24 12:14:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060424121423-naev53qigqgks0sa
Tags: 1.2.9-1
New upstream  release Fixes  three security  problems: CVE-2006-1546,
CVE-2006-1547,  CVE-2006-1548  (closes:  #360551),  thanks  to  Moritz
Muehlenhoff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
 
2
<%@page import="junit.framework.Assert"%>
 
3
<%@page import="org.apache.struts.Globals"%>
 
4
<%@page import="org.apache.struts.action.ActionMessage"%>
 
5
<%@page import="org.apache.struts.action.ActionMessages"%>
 
6
 
 
7
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
 
8
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
 
9
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
 
10
 
 
11
 
 
12
<logic:equal name="runTest" value="testPasswordPropertyReadonly">
 
13
        <bean:define id="TEST_RESULTS" toScope="page">
 
14
                <html:password property="string" readonly="true"/>
 
15
        </bean:define>
 
16
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
17
                <input type="password" name="string" value="Test Value" readonly="readonly">
 
18
        </bean:define>
 
19
</logic:equal>
 
20
 
 
21
<logic:equal name="runTest" value="testPasswordPropertySize">
 
22
        <bean:define id="TEST_RESULTS" toScope="page">
 
23
                <html:password property="string" size="10"/>
 
24
        </bean:define>
 
25
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
26
                <input type="password" name="string" size="10" value="Test Value">
 
27
        </bean:define>
 
28
</logic:equal>
 
29
 
 
30
<logic:equal name="runTest" value="testPasswordPropertyStyle">
 
31
        <bean:define id="TEST_RESULTS" toScope="page">
 
32
                <html:password property="string" style="Put something here"  errorStyle="some error style"/>
 
33
        </bean:define>
 
34
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
35
                <input type="password" name="string" value="Test Value" style="Put something here">
 
36
        </bean:define>
 
37
</logic:equal>
 
38
 
 
39
<logic:equal name="runTest" value="testPasswordPropertyErrorStyle">
 
40
<%
 
41
    ActionMessages errors = new ActionMessages();
 
42
    errors.add("string",
 
43
         new ActionMessage("default.testing.errors.tag"));
 
44
    request.setAttribute("ALT_ERROR_KEY", errors);
 
45
%>
 
46
        <bean:define id="TEST_RESULTS" toScope="page">
 
47
                <html:password property="string" style="Put something here"  errorStyle="some error style" errorKey="ALT_ERROR_KEY"/>
 
48
        </bean:define>
 
49
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
50
                <input type="password" name="string" value="Test Value" style="some error style">
 
51
        </bean:define>
 
52
</logic:equal>
 
53
 
 
54
<logic:equal name="runTest" value="testPasswordPropertyStyleClass">
 
55
        <bean:define id="TEST_RESULTS" toScope="page">
 
56
                <html:password property="string" styleClass="Put something here" errorStyleClass="some error style class"/>
 
57
        </bean:define>
 
58
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
59
                <input type="password" name="string" value="Test Value" class="Put something here">
 
60
        </bean:define>
 
61
</logic:equal>
 
62
 
 
63
<logic:equal name="runTest" value="testPasswordPropertyErrorStyleClass">
 
64
<%
 
65
    ActionMessages errors = new ActionMessages();
 
66
    errors.add("string",
 
67
         new ActionMessage("default.testing.errors.tag"));
 
68
    request.setAttribute(Globals.ERROR_KEY, errors);
 
69
%>
 
70
        <bean:define id="TEST_RESULTS" toScope="page">
 
71
                <html:password property="string" styleClass="Put something here" errorStyleClass="some error style class"/>
 
72
        </bean:define>
 
73
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
74
                <input type="password" name="string" value="Test Value" class="some error style class">
 
75
        </bean:define>
 
76
</logic:equal>
 
77
 
 
78
<logic:equal name="runTest" value="testPasswordPropertyStyleId">
 
79
        <bean:define id="TEST_RESULTS" toScope="page">
 
80
                <html:password property="string" styleId="Put something here" errorStyleId="some error style id"/>
 
81
        </bean:define>
 
82
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
83
                <input type="password" name="string" value="Test Value" id="Put something here">
 
84
        </bean:define>
 
85
</logic:equal>
 
86
 
 
87
<logic:equal name="runTest" value="testPasswordPropertyErrorStyleId">
 
88
<%
 
89
    ActionMessages errors = new ActionMessages();
 
90
    errors.add("string",
 
91
         new ActionMessage("default.testing.errors.tag"));
 
92
    request.setAttribute(Globals.ERROR_KEY, errors);
 
93
%>
 
94
        <bean:define id="TEST_RESULTS" toScope="page">
 
95
                <html:password property="string" styleId="Put something here" errorStyleId="some error style id"/>
 
96
        </bean:define>
 
97
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
98
                <input type="password" name="string" value="Test Value" id="some error style id">
 
99
        </bean:define>
 
100
</logic:equal>
 
101
 
 
102
<logic:equal name="runTest" value="testPasswordPropertyTitle">
 
103
        <bean:define id="TEST_RESULTS" toScope="page">
 
104
                <html:password property="string" title="Put something here"/>
 
105
        </bean:define>
 
106
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
107
                <input type="password" name="string" value="Test Value" title="Put something here">
 
108
        </bean:define>
 
109
</logic:equal>
 
110
 
 
111
<logic:equal name="runTest" value="testPasswordPropertyTitleKey">
 
112
        <bean:define id="TEST_RESULTS" toScope="page">
 
113
                <html:password property="string" titleKey="default.bundle.message"/>
 
114
        </bean:define>
 
115
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
116
                <input type="password" name="string" value="Test Value" title="Testing Message">
 
117
        </bean:define>
 
118
</logic:equal>
 
119
 
 
120
<logic:equal name="runTest" value="testPasswordPropertyTitleKey_fr">
 
121
        <bean:define id="TEST_RESULTS" toScope="page">
 
122
                <html:password property="string" titleKey="default.bundle.message"/>
 
123
        </bean:define>
 
124
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
125
                <input type="password" name="string" value="Test Value" title="Message D'Essai">
 
126
        </bean:define>
 
127
</logic:equal>
 
128
 
 
129
<logic:equal name="runTest" value="testPasswordPropertyValue">
 
130
        <bean:define id="TEST_RESULTS" toScope="page">
 
131
                <html:password property="string" value ="Put something here"/>
 
132
        </bean:define>
 
133
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
134
                <input type="password" name="string" value="Put something here">
 
135
        </bean:define>
 
136
</logic:equal>
 
137
 
 
138
<logic:equal name="runTest" value="testPasswordPropertyIndexedArray">
 
139
        <bean:define id="TEST_RESULTS" toScope="page">
 
140
          <logic:iterate id="indivItem" name="lst">
 
141
                <html:password property="string" indexed="true"/>
 
142
          </logic:iterate>
 
143
        </bean:define>
 
144
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
145
        
 
146
                <input type="password" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value">
 
147
                
 
148
        </bean:define>
 
149
</logic:equal>
 
150
 
 
151
<logic:equal name="runTest" value="testPasswordPropertyIndexedArrayProperty">
 
152
        <bean:define id="TEST_RESULTS" toScope="page">
 
153
          <logic:iterate id="indivItem" name="lst" property="list">
 
154
                <html:password property="string" indexed="true"/>
 
155
          </logic:iterate>
 
156
        </bean:define>
 
157
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
158
        
 
159
                <input type="password" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value">
 
160
                
 
161
        </bean:define>
 
162
</logic:equal>
 
163
 
 
164
<logic:equal name="runTest" value="testPasswordPropertyIndexedMap">
 
165
        <bean:define id="TEST_RESULTS" toScope="page">
 
166
          <logic:iterate id="indivItem" name="lst">
 
167
                <html:password property="string" indexed="true"/>
 
168
          </logic:iterate>
 
169
        </bean:define>
 
170
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
171
        
 
172
                <input type="password" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value">
 
173
                
 
174
        </bean:define>
 
175
</logic:equal>
 
176
 
 
177
<logic:equal name="runTest" value="testPasswordPropertyIndexedMapProperty">
 
178
        <bean:define id="TEST_RESULTS" toScope="page">
 
179
          <logic:iterate id="indivItem" name="lst" property="map">
 
180
                <html:password property="string" indexed="true"/>
 
181
          </logic:iterate>
 
182
        </bean:define>
 
183
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
184
        
 
185
                <input type="password" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value">
 
186
                
 
187
        </bean:define>
 
188
</logic:equal>
 
189
 
 
190
<logic:equal name="runTest" value="testPasswordPropertyIndexedEnumeration">
 
191
        <bean:define id="TEST_RESULTS" toScope="page">
 
192
        <logic:iterate id="indivItem" name="lst">
 
193
                <html:password property="string" indexed="true"/>
 
194
        </logic:iterate>
 
195
        </bean:define>
 
196
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
197
        
 
198
                <input type="password" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value">
 
199
        
 
200
                <input type="password" name="org.apache.struts.taglib.html.BEAN[1].string" value="Test Value">
 
201
        
 
202
        </bean:define>
 
203
</logic:equal>
 
204
 
 
205
<logic:equal name="runTest" value="testPasswordPropertyIndexedEnumerationProperty">
 
206
        <bean:define id="TEST_RESULTS" toScope="page">
 
207
        <logic:iterate id="indivItem" name="lst" property="enumeration">
 
208
                <html:password property="string" indexed="true"/>
 
209
        </logic:iterate>
 
210
        </bean:define>
 
211
        <bean:define id="EXPECTED_RESULTS" toScope="page">
 
212
        
 
213
                <input type="password" name="org.apache.struts.taglib.html.BEAN[0].string" value="Test Value">
 
214
        
 
215
                <input type="password" name="org.apache.struts.taglib.html.BEAN[1].string" value="Test Value">
 
216
        
 
217
        </bean:define>
 
218
</logic:equal>
 
219
 
 
220
 
 
221
 
 
222
<% 
 
223
String expected = "";
 
224
String compareTo = "";
 
225
 
 
226
if (pageContext.getAttribute("EXPECTED_RESULTS") == null){
 
227
    throw new javax.servlet.jsp.JspException("No tests on this page were called.  Please verify that you've setup the tests correctly.");
 
228
}else{
 
229
        expected=pageContext.getAttribute("EXPECTED_RESULTS").toString();
 
230
}
 
231
if (pageContext.getAttribute("TEST_RESULTS") != null){
 
232
        compareTo=pageContext.getAttribute("TEST_RESULTS").toString();
 
233
}
 
234
 
 
235
Assert.assertEquals(expected, compareTo);
 
236
%>