Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wyona/yanel into small-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric Staub committed Aug 9, 2012
2 parents d7d0e5f + b52d00d commit 6d88ff8
Show file tree
Hide file tree
Showing 29 changed files with 1,314 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.txt
Expand Up @@ -6,7 +6,7 @@
Requirements and Prerequisites
------------------------------

Java Development Kit version 1.6 or higher (e.g. http://java.sun.com).
Java Development Kit version 1.6 or higher (e.g. http://java.oracle.com).

NOTES:

Expand Down
3 changes: 3 additions & 0 deletions src/build/build.properties
Expand Up @@ -96,6 +96,9 @@ duplicated.libs=apache-jakarta-commons-codec-1.3.jar,\
commons-lang-2.2.jar,\
commons-lang-2.3.jar,\
commons-lang-2.4.jar,\
commons-logging-1.0.4.jar,\
apache-jakarta-commons-logging-1.0.4.jar,\
commons-logging-1.1.jar,\
commons-beanutils-1.6.jar,\
commons-collections-2.1.jar,\
commons-collections-3.1.jar,\
Expand Down
7 changes: 4 additions & 3 deletions src/build/dependencies.xml
Expand Up @@ -41,6 +41,7 @@

<dependency groupId="log4j" artifactId="log4j" version="1.2.16"/>
<dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.5.8"/>
<dependency groupId="commons-logging" artifactId="commons-logging" version="1.1.1"/>

<!-- INFO: JAXB implementation -->
<dependency groupId="org.eclipse.persistence" artifactId="org.eclipse.persistence.moxy" version="2.3.2"/>
Expand All @@ -63,7 +64,7 @@
-->

<!-- IMPORTANT: Please make sure to update pom-core.xml as well! -->
<dependency groupId="wyona-org-security" artifactId="wyona-org-security-core" version="1.2.0-r18da65494e8c0731ff4762068632e90859246e97"/>
<dependency groupId="wyona-org-security" artifactId="wyona-org-security-core" version="1.3.0-rf23d2fea13dec0d3ccc536e67decfdbd1f07f50c"/>

<!-- TODO: Add to yanel.xml, because these libs are only needed during runtime -->
<dependency groupId="avalon-framework" artifactId="avalon-framework-api" version="4.3"/>
Expand All @@ -86,8 +87,8 @@
<!-- IMPORTANT: Please also see src/build/targets/webapp/webapp.xml re ambiguous libs -->
<dependency groupId="xalan" artifactId="xalan" version="2.7.0"/>

<dependency groupId="wyona-org-security" artifactId="wyona-org-security-impl" version="1.2.0-r18da65494e8c0731ff4762068632e90859246e97"/>
<dependency groupId="wyona-org-security" artifactId="wyona-org-security-util" version="1.2.0-r18da65494e8c0731ff4762068632e90859246e97"/>
<dependency groupId="wyona-org-security" artifactId="wyona-org-security-impl" version="1.3.0-rf23d2fea13dec0d3ccc536e67decfdbd1f07f50c"/>
<dependency groupId="wyona-org-security" artifactId="wyona-org-security-util" version="1.3.0-rf23d2fea13dec0d3ccc536e67decfdbd1f07f50c"/>
<!-- IMPORTANT: Please make sure to update pom-core.xml as well! -->
<dependency groupId="yarep" artifactId="yarep-impl" version="1.0-dev-rad19798901b2280b7236e915ae96746ab630fcc1"/>
<dependency groupId="spring" artifactId="spring"
Expand Down
6 changes: 3 additions & 3 deletions src/build/pom-core.xml
Expand Up @@ -10,19 +10,19 @@
<groupId>wyona-org-security</groupId>
<artifactId>wyona-org-security-core</artifactId>
<!-- IMPORTANT: Please make sure to update dependencies.xml as well! -->
<version>1.2.0-r18da65494e8c0731ff4762068632e90859246e97</version>
<version>1.3.0-rf23d2fea13dec0d3ccc536e67decfdbd1f07f50c</version>
</dependency>
<dependency>
<groupId>wyona-org-security</groupId>
<artifactId>wyona-org-security-impl</artifactId>
<!-- IMPORTANT: Please make sure to update dependencies.xml as well! -->
<version>1.2.0-r18da65494e8c0731ff4762068632e90859246e97</version>
<version>1.3.0-rf23d2fea13dec0d3ccc536e67decfdbd1f07f50c</version>
</dependency>
<dependency>
<groupId>wyona-org-security</groupId>
<artifactId>wyona-org-security-util</artifactId>
<!-- IMPORTANT: Please make sure to update dependencies.xml as well! -->
<version>1.2.0-r18da65494e8c0731ff4762068632e90859246e97</version>
<version>1.3.0-rf23d2fea13dec0d3ccc536e67decfdbd1f07f50c</version>
</dependency>
<dependency>
<groupId>yarep</groupId>
Expand Down
5 changes: 2 additions & 3 deletions src/build/resource-types/GWT-RT.build.xml
Expand Up @@ -2,6 +2,8 @@

<!-- Everything common to resource types using Google Web Toolkit. -->

<!-- INFO: If you only want to compile regular java classes, but no GWT classes, then run './build.sh -Dgwt.compile.skip=true' (Also see http://www.yanel.org/en/documentation/best-practices/rapid-development-of-components.html) -->

<project name="yanel-GWT-resource-type"
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
>
Expand Down Expand Up @@ -134,9 +136,6 @@ module.build.dir.includes: ${module.build.dir.includes}

<!-- @Override resource-type.build.xml#compile -->
<target name="compile" depends="yanel-resource-type.compile, gwt:compile" description="Compile Java classes and GWT files"/>
<!-- INFO: Only compile regular java classes, but no gwt-classes
<target name="compile" depends="yanel-resource-type.compile" description="Compile only Java classes and no GWT files"/>
-->

<target name="gwt:compile" depends="gwt:clean" description="Compile GWT files" unless="gwt.compile.skip">

Expand Down
Expand Up @@ -56,7 +56,7 @@
</target>

<target name="startup-tomcat-unix" if="isUnix">
<fail message="No Tomcat is set within local.build.properties!">
<fail message="No Tomcat is set inside local.build.properties! Please note that if you build Yanel from scratch, then you should use the 'quick-start' target (https://github.com/wyona/yanel).">
<condition>
<and>
<not>
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;

import org.wyona.security.core.api.Identity;
import java.lang.Integer;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -80,6 +81,14 @@ public View getView(String viewId, String revisionName) throws Exception {
response.setStatus(307);
response.setHeader("Location", defaultHref);

// Username
String currentUser = null;
Identity identity = getIdentity(getRequest());
if (identity != null) {
currentUser = identity.getUsername();
}
boolean isLoggedIn = currentUser != null;

ResourceConfiguration rc = getConfiguration();
Document customConfigDoc = rc.getCustomConfiguration();
if (customConfigDoc != null) {
Expand All @@ -94,11 +103,17 @@ public View getView(String viewId, String revisionName) throws Exception {
log.debug("Localization: " + localizationLanguage);
for (int i = 0; i < languageRedirectConfigs.length; i++) {
try {
if (languageRedirectConfigs[i].getAttribute("code").equals(localizationLanguage)) {
String lang = languageRedirectConfigs[i].getAttribute("code");
if (lang.equals(localizationLanguage) || lang.equals("*")) {
response.setStatus(307);
String href = languageRedirectConfigs[i].getAttribute("href");
response.setHeader("Location", href);

String if_logged_in = languageRedirectConfigs[i].getAttribute("if-logged-in", "false");
if("true".equals(if_logged_in) && !isLoggedIn) {
continue;
}

String device = languageRedirectConfigs[i].getAttribute("device", null);
if (device != null) {
if (device.equals("web.xml:mobile-devices")) {
Expand All @@ -125,13 +140,6 @@ public View getView(String viewId, String revisionName) throws Exception {
}
}


// Username
String currentUser = null;
Identity identity = getIdentity(getRequest());
if (identity != null) {
currentUser = identity.getUsername();
}
if (currentUser != null) {
Configuration[] userRedirectConfigs = config.getChildren("user");
for (int i = 0; i < userRedirectConfigs.length; i++) {
Expand Down
@@ -0,0 +1,6 @@
<?xml version="1.0"?>

<policy-map>
<matcher pattern="*.tinymce-edit.html" path="/tinymce-policy.xml"/>
<matcher pattern="/**/create-new-page.html" path="/create-new-page.html.policy"/>
</policy-map>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>

<policy xmlns="http://www.wyona.org/security/1.0">

<usecase id="view">
<world permission="false"/>
<user id="lenya" permission="true"/>
</usecase>

<usecase id="open">
<user id="lenya" permission="true"/>
</usecase>

<usecase id="write">
<user id="lenya" permission="true"/>
</usecase>

</policy>
@@ -0,0 +1,4 @@
local.build.properties
results
definitions.xml
dtd/Project.dtd
49 changes: 49 additions & 0 deletions src/realms/from-scratch-realm-template/src/test/canoo/README.txt
@@ -0,0 +1,49 @@

Canoo Webtests for From Scratch Realm
=====================================

How to install and run the tests
--------------------------------

1. Download and install canoo webtest package
http://webtest.canoo.com/webtest/manual/Downloads.html (Successfully tested with revision canoo-3.0-1758)

2. Unzip build.zip e.g. to /home/USERNAME/local/canoo-VERSION_r_REVISION

3. Copy build.properties to local.build.properties and edit local.build.properties according to your local settings, for example set
webtest.home=/home/USERNAME/local/canoo-VERSION_r_REVISION

4. Start web-application server (for example Tomcat)
(IMPORTANT: Make sure to set target environment inside 'TOMCAT/webapps/yanel/WEB-INF/classes/yanel.xml' to 'ci-test')
(IMPORTANT: Make sure that Yanel has SSL NOT configured, check YANEL_HOME/src/build/local.build.properties or TOMCAT/webapps/yanel/WEB-INF/web.xml)
(IMPORTANT: The language is configured inside includes/config.xml, but also inside the user itself ac-identities/users/lenya.xml)

5. Type 'ant' (IMPORTANT: Make sure to use version 1.7.x) to run all the tests (You might have to reset your PATH environment variable, for example 'export PATH=/home/USER/yanel/tools/apache-ant/bin:$PATH')

In order to run just "one" particular test, please type 'ant -Dwt.testInWork=tests/single-page.xml' or 'ant -Dwt.testInWork=tests/single-page/add-related-content-element.xml'



How to add new tests
--------------------

0. Add new tests to ./tests/allTests.xml

1. download and install the webtestrecorder firefox plugin
http://webtestrecorder.canoo.com/install.html

2. record a test in the browser

3. make a copy of one of the test files under ./tests

4. edit the file and replace the actual test code with the recorded code

5. clean up the code if necessary



Known bugs
----------

the recorder plugin has a problem with XHTML strict.
somehow it doesn't record all events (e.g. clickButton).
@@ -0,0 +1,11 @@

# file system path of canoo webtest package (http://webtest.canoo.com/webtest/build.zip)
webtest.home=/home/USERNAME/canoo-3.0-1758

# {protocol}://{host}:{port}/{basepath}
webtest.config.host=127.0.0.1
webtest.config.port=8080
webtest.config.protocol=http
webtest.config.basepath=yanel

realm.path=from-scratch-realm/
19 changes: 19 additions & 0 deletions src/realms/from-scratch-realm-template/src/test/canoo/build.xml
@@ -0,0 +1,19 @@
<?xml version="1.0"?>

<project name="canoo-web-tests" default="wt.full">

<property file="local.build.properties"/>
<property file="build.properties"/>

<!-- <import file="definitions.xml" description="Import custom definitions (if any)"/> -->
<import file="${webtest.home}/webtest.xml" description="Import all functionalities for a full build"/>

<property name="wt.testInWork" value="tests/allTests.xml"/>

<!--
Activate this if you are behind a proxy and want to test a server outside your local network
See http://ant.apache.org/manual/OptionalTasks/setproxy.html
<setproxy proxyhost="myProxy" proxyport="1234"/>
-->

</project>
@@ -0,0 +1,21 @@
<!--
Like all files of this folder, this content will be executed in target wt.defineMacros
and therefore made be available for the tests (here the macro <fillParticipantData .../>)
-->
<macrodef name="login" description="Login">
<sequential>
<invoke description="Load the toolbar to procede with the login"
url="${realm.path}de/index.html?yanel.toolbar=on" />
<ifStep>
<condition>
<verifyXPath description="Check if login available"
xpath="count(//input[@name='yanel.login.username']) &gt; 0" />
</condition>
<!-- Log in -->
<setInputField name="yanel.login.username" value="lenya" />
<setInputField name="yanel.login.password" value="levi" />
<clickButton label="Login" fieldIndex="0"/>
</ifStep>
<!-- Assume logged in -->
</sequential>
</macrodef>
@@ -0,0 +1,12 @@
<!--
Like all files of this folder, this content will be executed in target wt.defineMacros
and therefore made be available for the tests (here the macro <fillParticipantData .../>)
-->
<macrodef name="logout" description="Logout">
<sequential>
<invoke description="Logout"
url="${realm.path}de/index.html?yanel.usecase=logout"/>
</sequential>
</macrodef>


@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!ENTITY % webtest SYSTEM "./WebTest.dtd" >
<!ENTITY % project SYSTEM "./Project.dtd">
%webtest;
%project;

0 comments on commit 6d88ff8

Please sign in to comment.