You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2019/03/02 23:12:00 UTC
[archiva] branch archiva-2.x updated (29e40ea -> d4be896)
This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a change to branch archiva-2.x
in repository https://gitbox.apache.org/repos/asf/archiva.git.
from 29e40ea Adding parameter checks
new be4dab1 Fixing web ui tests
new cc0d8ad Adding additional verifications for upload
new d4be896 Adding error handling for new validations. Fix web ui tests.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../archiva/web/api/DefaultFileUploadService.java | 29 +++++++++++++++++++---
.../org/apache/archiva/i18n/default.properties | 4 +++
.../archiva-web/archiva-webapp-test/pom.xml | 23 ++++++++++++++---
.../archiva/web/test/WebDriverBrowseTest.java | 10 +++++---
.../org/apache/archiva/web/test/WebDriverTest.java | 7 +++++-
.../web/test/parent/AbstractSeleniumTest.java | 17 ++++++++++++-
.../main/webapp/js/archiva/artifacts-management.js | 13 ++++++----
.../src/main/webapp/js/archiva/utils.js | 2 +-
.../webapp/js/templates/archiva/general-admin.html | 4 +--
9 files changed, 89 insertions(+), 20 deletions(-)
[archiva] 03/03: Adding error handling for new validations. Fix web
ui tests.
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a commit to branch archiva-2.x
in repository https://gitbox.apache.org/repos/asf/archiva.git
commit d4be8968cfb9910f335009e1538292671aa67853
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Sun Mar 3 00:11:52 2019 +0100
Adding error handling for new validations. Fix web ui tests.
---
.../resources/org/apache/archiva/i18n/default.properties | 4 ++++
archiva-modules/archiva-web/archiva-webapp-test/pom.xml | 1 +
.../src/main/webapp/js/archiva/artifacts-management.js | 13 ++++++++-----
.../archiva-webapp/src/main/webapp/js/archiva/utils.js | 2 +-
.../src/main/webapp/js/templates/archiva/general-admin.html | 4 ++--
5 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
index 122db4f..5f21bba 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
@@ -546,6 +546,7 @@ fileupload.errors.acceptFileTypes=Filetype not allowed
fileupload.errors.maxNumberOfFiles=Max number of files exceeded
fileupload.errors.uploadedBytes=Uploaded bytes exceed file size
fileupload.errors.emptyResult=Empty file upload result
+fileupload.errors.Unprocessable_Entity=There were illegal characters in the parameters
fileupload.artifactId=Artifact ID
fileupload.groupId=Groupd ID
fileupload.version=Version
@@ -556,6 +557,9 @@ fileupload.save=Save Files
fileupload.upload.required=You must upload your files first.
fileupload.artifacts.saved=Artifacts for ''{0}:{1}:{2}'', packaged as ''{3}'', with {4} POM Generated, were uploaded and saved on Server side to ''{5}'' repository.
fileupload.deleteAll=Select All
+fileupload.malformed.param=The field contains illegal characters.
+fileupload.malformed.filename=The filename contains illegal characters.
+fileupload.malformed.pomFile=The field pomFile has no boolean value.
#reports
report.title = Reports
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
index 2dbe3d2..f3c4b01 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
@@ -574,6 +574,7 @@
<executions>
<execution>
<id>cleanup-files</id>
+ <phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js
index aa96a83..ab8b307 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js
@@ -47,8 +47,11 @@ define("archiva.artifacts-management",["jquery","i18n","utils","jquery.tmpl","kn
displayErrorMessage( $.i18n.prop("fileupload.upload.required"));
return;
}
- var url="restServices/archivaUiServices/fileUploadService/save/"+this.repositoryId()+"/"+this.groupId()+"/"+this.artifactId();
- url+="/"+this.version()+"/"+this.packaging();
+ var url="restServices/archivaUiServices/fileUploadService/save/"+encodeURI(this.repositoryId())
+ +"/"+encodeURIComponent(this.groupId())
+ +"/"+encodeURIComponent(this.artifactId())
+ +"/"+encodeURIComponent(this.version())
+ +"/"+encodeURIComponent(this.packaging());
$.log("this.generatePom():'"+this.generatePom()+"'");
if (this.generatePom()==true){
url+="?generatePom=true";
@@ -117,9 +120,9 @@ define("archiva.artifacts-management",["jquery","i18n","utils","jquery.tmpl","kn
if (!data.formData){
data.formData={};
}
- data.formData.pomFile = pomFile;
- data.formData.classifier = classifier;
- data.formData.packaging = packaging;
+ data.formData.pomFile = encodeURIComponent(pomFile);
+ data.formData.classifier = encodeURIComponent(classifier);
+ data.formData.packaging = encodeURIComponent(packaging);
});
}
});
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
index 7c0db1c..5802adc 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
@@ -284,7 +284,7 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
if (mainContent.find("#"+data.fieldName)){
var message=null;
if (data.errorKey) {
- message=$.i18n.prop('data.errorKey');
+ message=$.i18n.prop(data.errorKey);
} else {
message=data.errorMessage;
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
index b377fbb..dc6e767 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
@@ -653,7 +653,7 @@
{% if (file.error) { %}
<td class="error" colspan="2">
<span class="label label-important">{%=$.i18n.prop('fileupload.error')%}</span>
- {%=$.i18n.prop('fileupload.errors.'+[file.error]) || file.error%}
+ {%=$.i18n.prop('fileupload.errors.'+file.error.replace(/\s+/,'_')) || file.error%}
</td>
{% } else if (o.files.valid && !i) { %}
<td>
@@ -692,7 +692,7 @@
{% if (file.error) { %}
<td class="error" colspan="2">
<span class="label label-important">{%=$.i18n.prop('fileupload.error')%}</span>
- {%=$.i18n.prop('fileupload.errors.'+[file.error]) || file.error%}
+ {%=$.i18n.prop('fileupload.errors.'+file.error.replace(/\s+/,'_')) || file.error%}
</td>
{% } else { %}
<td colspan="2"></td>
[archiva] 02/03: Adding additional verifications for upload
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a commit to branch archiva-2.x
in repository https://gitbox.apache.org/repos/asf/archiva.git
commit cc0d8ad0b525e641855319812877fdc6c8cd327c
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Sun Mar 3 00:10:49 2019 +0100
Adding additional verifications for upload
---
.../archiva/web/api/DefaultFileUploadService.java | 29 +++++++++++++++++++---
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
index 4fd8f68..7119986 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
@@ -69,6 +69,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
+import java.net.URLDecoder;
import java.nio.file.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -115,7 +116,8 @@ public class DefaultFileUploadService
throws IOException
{
Attachment attachment = multipartBody.getAttachment( attachmentId );
- return attachment == null ? "" : IOUtils.toString( attachment.getDataHandler().getInputStream() );
+ return attachment == null ? "" :
+ StringUtils.trim(URLDecoder.decode(IOUtils.toString( attachment.getDataHandler().getInputStream() ), "UTF-8"));
}
@Override
@@ -128,9 +130,26 @@ public class DefaultFileUploadService
String classifier = getStringValue( multipartBody, "classifier" );
String packaging = getStringValue( multipartBody, "packaging" );
+
+ checkParamChars( "classifier", classifier );
+ checkParamChars( "packaging", packaging);
+
// skygo: http header form pomFile was once sending 1 for true and void for false
// leading to permanent false value for pomFile if using toBoolean(); use , "1", ""
- boolean pomFile = BooleanUtils.toBoolean( getStringValue( multipartBody, "pomFile" ) );
+
+ boolean pomFile = false;
+ try
+ {
+ pomFile = BooleanUtils.toBoolean( getStringValue( multipartBody, "pomFile" ) );
+ }
+ catch ( IllegalArgumentException ex )
+ {
+ ArchivaRestServiceException e = new ArchivaRestServiceException("Bad value for boolean pomFile field.", null);
+ e.setHttpErrorCode(422);
+ e.setFieldName( "pomFile" );
+ e.setErrorKey("fileupload.malformed.pomFile");
+ throw e;
+ }
Attachment file = multipartBody.getAttachment( "files[]" );
@@ -141,7 +160,7 @@ public class DefaultFileUploadService
ArchivaRestServiceException e = new ArchivaRestServiceException("Bad filename in upload content: " + fileName + " - File traversal chars (..|/) are not allowed"
, null);
e.setHttpErrorCode(422);
- e.setErrorKey("error.upload.malformed.filename");
+ e.setErrorKey("fileupload.malformed.filename");
throw e;
}
@@ -249,7 +268,7 @@ public class DefaultFileUploadService
if (!hasValidChars(value)) {
ArchivaRestServiceException e = new ArchivaRestServiceException("Bad characters in " + param, null);
e.setHttpErrorCode(422);
- e.setErrorKey("error.upload.malformed.param." + param);
+ e.setErrorKey("fileupload.malformed.param");
e.setFieldName(param);
throw e;
}
@@ -269,8 +288,10 @@ public class DefaultFileUploadService
checkParamChars("repositoryId", repositoryId);
checkParamChars("groupId", groupId);
checkParamChars("artifactId", artifactId);
+ checkParamChars( "version", version);
checkParamChars("packaging", packaging);
+
List<FileMetadata> fileMetadatas = getSessionFilesList();
if ( fileMetadatas == null || fileMetadatas.isEmpty() )
{
[archiva] 01/03: Fixing web ui tests
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a commit to branch archiva-2.x
in repository https://gitbox.apache.org/repos/asf/archiva.git
commit be4dab11592ec402fb4349f84fe7c535ce889abc
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Sat Mar 2 18:56:59 2019 +0100
Fixing web ui tests
---
.../archiva-web/archiva-webapp-test/pom.xml | 22 +++++++++++++++++++---
.../archiva/web/test/WebDriverBrowseTest.java | 10 +++++++---
.../org/apache/archiva/web/test/WebDriverTest.java | 7 ++++++-
.../web/test/parent/AbstractSeleniumTest.java | 17 ++++++++++++++++-
4 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
index ecff6b4..2dbe3d2 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-web</artifactId>
- <version>2.2.3-SNAPSHOT</version>
+ <version>2.2.4-SNAPSHOT</version>
</parent>
<artifactId>archiva-webapp-test</artifactId>
<packaging>pom</packaging>
@@ -210,7 +210,23 @@
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.24</version>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>16.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-chrome-driver</artifactId>
+ <version>${selenium-server.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-support</artifactId>
+ <version>${selenium-server.version}</version>
+ </dependency>
+
</dependencies>
</plugin>
<plugin>
@@ -563,7 +579,7 @@
</goals>
<configuration>
<tasks>
- <delete file="${user.home}/.m2/archiva.xml" quiet="true"/>
+ <delete file="${user.home}/.m2/archiva.xml" quiet="true" />
</tasks>
</configuration>
</execution>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java
index 4ed311d..09c3927 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverBrowseTest.java
@@ -115,12 +115,16 @@ public class WebDriverBrowseTest
fill( "#confirmPassword" ).with( p.getProperty( "ADMIN_PASSWORD" ) );
find( "#user-create-form-register-button" ).click();
- await().atMost( 2, TimeUnit.SECONDS ).until( "#logout-link" ).isPresent();
+ await().atMost( 10, TimeUnit.SECONDS ).until( "#logout-link" ).isPresent();
+ await().atMost( 10, TimeUnit.SECONDS ).until( "#footer-content" ).isPresent();
- FluentList<FluentWebElement> elementss = find( "#menu-find-browse-a" );
+ FluentList<FluentWebElement> elementss = find( "#menu-find-search-a" );
WebElement webElsement = elementss.get( 0 ).getElement();
webElsement.click();
- await().atMost( 2, TimeUnit.SECONDS ).until( "#main_browse_result" ).isPresent();
+ elementss = find( "#menu-find-browse-a" );
+ webElsement = elementss.get( 0 ).getElement();
+ webElsement.click();
+ await().atMost( 120, TimeUnit.SECONDS ).until( "#main_browse_result" ).isPresent();
// give me search page :( not browse page
takeScreenShot( "search.png" );
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java
index deec6c0..0da5bf1 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/WebDriverTest.java
@@ -44,6 +44,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.fluentlenium.core.Fluent;
import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Olivier Lamy
@@ -51,13 +53,15 @@ import org.junit.Before;
public class WebDriverTest
extends FluentTest {
+ Logger logger = LoggerFactory.getLogger( WebDriverTest.class );
+
@Override
public Fluent takeScreenShot(String fileName) {
try {
// save html to have a minimum feedback if jenkins firefox not up
File fileNameHTML = new File(fileName + ".html");
FileUtils.writeStringToFile(fileNameHTML, getDriver().getPageSource());
- } catch (IOException e) {
+ } catch (Throwable e) {
System.out.print(e.getMessage());
e.printStackTrace();
}
@@ -104,6 +108,7 @@ public class WebDriverTest
String seleniumHost = System.getProperty("seleniumHost", "localhost");
int seleniumPort = Integer.getInteger("seleniumPort", 4444);
try {
+ logger.info("Remote Web Driver: {}, {}", seleniumBrowser, seleniumPort);
if (StringUtils.contains(seleniumBrowser, "chrome")) {
return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"),
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
index 3a886c7..5890cee 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
@@ -37,6 +37,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -45,6 +47,7 @@ import org.apache.commons.io.FileUtils;
public abstract class AbstractSeleniumTest
{
+ final Logger logger = LoggerFactory.getLogger( AbstractSeleniumTest.class );
@Rule
public ArchivaSeleniumExecutionRule archivaSeleniumExecutionRule = new ArchivaSeleniumExecutionRule();
@@ -83,7 +86,9 @@ public abstract class AbstractSeleniumTest
baseUrl = "http://localhost:" + tomcatPort + "/archiva/index.html?request_lang=en";
+
open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs );
+ logger.info("Selected Browser: {}", browser);
archivaSeleniumExecutionRule.selenium = selenium;
assertAdminCreated();
}
@@ -701,7 +706,17 @@ public abstract class AbstractSeleniumTest
File fileName = new File( targetPath, fileBaseName + ".png" );
- selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "background=#FFFFFF" );
+ try
+ {
+ selenium.captureEntirePageScreenshot( fileName.getAbsolutePath( ), "background=#FFFFFF" );
+ } catch (Throwable e) {
+ try
+ {
+ selenium.captureScreenshot( fileName.getAbsolutePath( ) );
+ } catch (Throwable e1) {
+ logger.error("Could not capture screenshot {}:", e1.getMessage(), e1);
+ }
+ }
return fileName.getAbsolutePath();
}