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
/**
*
*/
package org.openiaml.model.tests.codegen.model0_4;

import java.util.List;

import org.eclipse.core.resources.IFile;

/**
* We explicitly define the login handler and the roles
* required.
*
* @example LoginHandler,AccessControlHandler,Session
* Restricting access to {@model Frame frames} contained
* within a {@model Session} by enforcing {@model LoginHandler user login}
* and checking the {@model DomainIterator current user} has a given {@model Role}.
* @implementation Session
* If a {@model Session} contains an {@model AccessControlHandler},
* it will check that the {@model DomainIterator current user} matches its
* {@model RequiresEdge access requirements}.
* @implementation Session
* If a {@model Session} contains a {@model LoginHandler} of type
* "user", access to pages contained within it will need to login to the current session.
* @author jmwright
*
*/
public class UserRolesLoginHandler extends AbstractUserLoginTestCase {

@Override
public void setUp() throws Exception {
super.setUp();
root = loadAndCodegen(UserRolesLoginHandler.class);
initialiseDatabase();
}

/**
* Check the initial state of the application.
*
* @throws Exception
*/
public void testInitial() throws Exception {
beginAtSitemapThenPage("Home");
}

/**
* We cannot access the protected page as a User
* because it does not have the appropriate Role.
*
* @throws Exception
*/
public void testUser() throws Exception {
IFile sitemap = doStandardLoginAs("user@openiaml.org", "user");
// we actually expect a problem, because user does not have 'default role' permissions
assertProblem();

// if we then try to go to 'target', we likewise will also be prevented
gotoSitemapWithProblem(sitemap, "target page");
assertTitleNotSame("target page");
assertProblem(); // who knows where we are?
}

/**
* Log in as 'Registered User'; passes
*
* @throws Exception
*/
public void testDefaultRole() throws Exception {
IFile sitemap = doStandardLoginAs("registered@openiaml.org", "test123");
assertNoProblem();

gotoSitemapThenPage(sitemap, "target page");
assertNoProblem();
}

@Override
protected List<String> getDatabaseInitialisers() {
List<String> s = super.getDatabaseInitialisers();
s.add("CREATE TABLE Registered_User (generated_primary_key INTEGER PRIMARY KEY AUTOINCREMENT, User_generated_primary_key INTEGER NOT NULL)");
s.add("INSERT INTO Registered_User (generated_primary_key, User_generated_primary_key) VALUES (44, 32)");
return s;
}

}

Change log

r3072 by soundasleep on Aug 8, 2011   Diff
fixing references to old metamodel
elements across project documentation
Go to: 
Project members, sign in to write a code review

Older revisions

r2154 by soundasleep on May 10, 2010   Diff
removing all explicit definitions of
getDatabaseName(), since 'default.db'
is now used by default (r2152)
r1730 by soundasleep on Mar 17, 2010   Diff
updating codegen tests to the correct
implementation of assertNoProblem()
r1640 by soundasleep on Mar 7, 2010   Diff
fixing all broken @model links in
javadoc, and genmodel docs
All revisions of this file

File info

Size: 2635 bytes, 84 lines
Powered by Google Project Hosting