My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/**
*
*/
package org.openiaml.model.tests.codegen.model0_5_1;

import org.eclipse.core.resources.IFile;
import org.openiaml.model.tests.CodegenTestCase;

/**
* @inference Gate,Label,RequiresEdge
* An entry {@model Gate} can {@model RequiresEdge require} a given {@model Label} to be
* set, creating a {@model Frame} that must be filled in before the containing {@model Scope}
* can be accessed.
*
* @example Gate
* Using an entry {@model Gate} to {@model RequiresEdge require} that a given
* contained {@model Label} is set.
*/
public class EntryGateRequiresOpenID extends CodegenTestCase {

// an OpenID that doesn't require passwords
final String openid = OpenIDAsAuthor.OPENID_PAGE_SERVER;

@Override
protected void setUp() throws Exception {
super.setUp();
root = loadAndCodegen(EntryGateRequiresOpenID.class);
}

/**
* The home page can be accessed.
*
* @throws Exception
*/
public void testHome() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();
}

/**
* Trying to access the session without the ID does not permit access to the session.
*
* @throws Exception
*/
public void testAccessWithoutID1() throws Exception {

// we try and access 'Secure Page', but we're redirected to 'Provide Current OpenID'
beginAtSitemapThenPage("Secure Page", "Provide Current OpenID");

// there are no problems though
assertNoProblem();

}

/**
* We try to access a protected page, but then we enter in a valid OpenID;
* once we return we can resume the gate and continue as normal.
*
* @throws Exception
*/
public void testAccessWithoutIDThenProvideIt() throws Exception {
doTestAccessWithoutIDThenProvideIt();
}

protected IFile doTestAccessWithoutIDThenProvideIt() throws Exception {

// we try and access 'Secure Page', but we're redirected to 'Provide Current OpenID'
IFile sitemap = beginAtSitemapThenPage("See Your OpenID", "Provide Current OpenID");
assertNoProblem();

// we will have a text field to enter in our OpenID
// set the URL
{
String target = getLabelIDForText("Current OpenID");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, openid);
}

// click the 'Authenticate' button
clickButtonWithText("Authenticate");
assertNoProblem();

// we should return back to the Provide page
assertTitleEquals("Provide Current OpenID");

// the URL is still there
{
String target = getLabelIDForText("Current OpenID");
assertLabeledFieldEquals(target, openid);
}

// we can click the 'Continue' button
clickButtonWithText("Continue");
assertNoProblem();

// we are now on the view ID page
assertTitleEquals("See Your OpenID");

// our OpenID is provided
assertLabelTextExactlyPresent(openid);

return sitemap;

}

/**
* We try to access a protected page, but then we enter in a valid OpenID; but, we
* don't validate, so we can't resume the page.
*
* @throws Exception
*/
public void testDontAuthenticate() throws Exception {

// we try and access 'Secure Page', but we're redirected to 'Provide Current OpenID'
beginAtSitemapThenPage("See Your OpenID", "Provide Current OpenID");

// we will have a text field to enter in our OpenID
// set the URL
{
String target = getLabelIDForText("Current OpenID");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, openid);
}

// DON'T click the Authenticate button
// we click the 'Continue' button
clickButtonWithText("Continue");

// but go back to the same page
assertTitleEquals("Provide Current OpenID");

// our OpenID is not a label anywhere
assertLabelTextNotPresent(openid);

}

/**
* We authenticate, then leave the Scope; we should be able to go back into
* the scope, as the Session stores the authentication.
*
* @throws Exception
*/
public void testAuthenticateThenLeaveScope() throws Exception {

// authenticate as normal
IFile sitemap = doTestAccessWithoutIDThenProvideIt();

// go back home
gotoSitemapThenPage(sitemap, "Home");
assertNoProblem();

// try go back into the session
gotoSitemapThenPage(sitemap, "Secure Page");
assertNoProblem();

}

/**
* We authenticate, but then reset the Session; we have to reauthenticate
* before we can get back into the Session.
*
* @throws Exception
*/
public void testAuthenticateThenRestartSession() throws Exception {

// authenticate as normal
IFile sitemap = doTestAccessWithoutIDThenProvideIt();

// restart session
restartSession(sitemap, "Home");

// try and view the same page again; we have to reauthenticate
gotoSitemapThenPage(sitemap, "See Your OpenID", "Provide Current OpenID");
assertNoProblem();

// our OpenID is not a label anywhere
assertLabelTextNotPresent(openid);

}

/**
* We can authenticate first, so we are never redirected.
*
* @throws Exception
*/
public void testAuthenticateFirst() throws Exception {

IFile sitemap = beginAtSitemapThenPage("Provide Current OpenID");
assertNoProblem();

// set the URL
{
String target = getLabelIDForText("Current OpenID");
assertLabeledFieldEquals(target, "");
setLabeledFormElementField(target, openid);
}

// click the 'Authenticate' button
clickButtonWithText("Authenticate");
assertNoProblem();

// we should return back to the Provide page
assertTitleEquals("Provide Current OpenID");

// we can now go directly to See Your OpenID
gotoSitemapThenPage(sitemap, "See Your OpenID");

// our OpenID is provided
assertLabelTextExactlyPresent(openid);

}

}

Change log

r3068 by soundasleep on Aug 8, 2011   Diff
improving modeldoc documentation across
inference rules, codegen templates, ecore,
and additional documentation includes
Go to: 
Project members, sign in to write a code review

Older revisions

r2216 by soundasleep on May 14, 2010   Diff
adding a codegen test case for
EntryGateRequiresOpenID (doesn't yet
pass)
All revisions of this file

File info

Size: 5793 bytes, 213 lines
Powered by Google Project Hosting