diff --git a/.gitignore b/.gitignore
index cfdc549..bc42b32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,9 +32,31 @@ local.properties
#################
## Java
#################
+# Compiled class file
*.class
*.jardesc
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
#################
## Visual Studio
#################
@@ -132,3 +154,43 @@ Thumbs.db
Desktop.ini
runtime.properties
+
+###############
+## Intellij
+###############
+# User-specific stuff
+.idea/
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+.idea/modules.xml
+.idea/*.iml
+.idea/modules
+*.iml
+*.ipr
+
+# CMake
+cmake-build-*/
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+*.log
+
diff --git a/pom.xml b/pom.xml
index 0e81a6d..60b1270 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
WaarpPassword
jar
Waarp Password Management GUI and Console
- 3.0.7
+ 3.1.0
Waarp Password Management GUI and Console
http://waarp.github.com/WaarpPassword
2009
@@ -45,7 +45,7 @@
Waarp
WaarpCommon
- 3.1.0
+ 3.1.1
ch.qos.logback
@@ -59,6 +59,12 @@
1.2.3
true
+
+ junit
+ junit
+ 4.12
+ test
+
UTF-8
@@ -86,7 +92,7 @@
1.6
true
- true
+ true
diff --git a/src/main/java/org/waarp/uip/Version.java b/src/main/java/org/waarp/uip/Version.java
index 0894588..80ba363 100644
--- a/src/main/java/org/waarp/uip/Version.java
+++ b/src/main/java/org/waarp/uip/Version.java
@@ -3,7 +3,7 @@
/** Provides the version information of Waarp Password. */
public final class Version {
/** The version identifier. */
- public static final String ID = "3.0.7";
+ public static final String ID = "3.1.0";
/** Prints out the version identifier to stdout. */
public static void main(String[] args) { System.out.println(ID); }
private Version() { super(); }
diff --git a/src/main/java/org/waarp/uip/WaarpPassword.java b/src/main/java/org/waarp/uip/WaarpPassword.java
index 9b33c4e..c44ad7a 100644
--- a/src/main/java/org/waarp/uip/WaarpPassword.java
+++ b/src/main/java/org/waarp/uip/WaarpPassword.java
@@ -32,6 +32,7 @@
import org.waarp.common.crypto.Des;
import org.waarp.common.crypto.KeyObject;
import org.waarp.common.exception.CryptoException;
+import org.waarp.common.utility.DetectionUtils;
import org.waarp.common.utility.SystemPropertyUtil;
import org.waarp.common.utility.WaarpStringUtils;
@@ -77,12 +78,18 @@ public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
if (!WaarpPassword.loadOptions(args)) {
// Bad options
+ if (DetectionUtils.isJunit()) {
+ return;
+ }
System.exit(2);
}
WaarpPassword waarpPassword = new WaarpPassword();
if (po == null && pi == null) {
// stop
System.err.println("Key written");
+ if (DetectionUtils.isJunit()) {
+ return;
+ }
System.exit(0);
}
if (waarpPassword.clearPassword == null || waarpPassword.clearPassword.length() == 0) {
@@ -90,6 +97,9 @@ public static void main(String[] args) throws Exception {
String newp = waarpPassword.readString();
if (newp == null || newp.length() == 0) {
System.err.println("No password as input");
+ if (DetectionUtils.isJunit()) {
+ return;
+ }
System.exit(4);
}
waarpPassword.setClearPassword(newp);
@@ -105,6 +115,15 @@ public static void main(String[] args) throws Exception {
}
public static boolean loadOptions(String[] args) {
+ desModel = true;
+ clearPasswordView = false;
+ ki = null;
+ ko = null;
+ pi = null;
+ po = null;
+ pwd = null;
+ cpwd = null;
+
int i = 0;
if (args.length == 0) {
System.err.println(HELPOPTIONS);
diff --git a/src/test/java/.gitkeep b/src/test/java/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/src/test/java/org/waarp/uip/WaarpPasswordTest.java b/src/test/java/org/waarp/uip/WaarpPasswordTest.java
new file mode 100644
index 0000000..26420b0
--- /dev/null
+++ b/src/test/java/org/waarp/uip/WaarpPasswordTest.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * This file is part of Waarp Project (named also Waarp or GG).
+ *
+ * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
+ * tags. See the COPYRIGHT.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * All Waarp Project is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * Waarp . If not, see .
+ ******************************************************************************/
+
+package org.waarp.uip;
+
+import org.junit.Test;
+import org.waarp.common.utility.DetectionUtils;
+import org.waarp.common.utility.WaarpStringUtils;
+
+import java.io.File;
+
+import static junit.framework.TestCase.*;
+
+public class WaarpPasswordTest {
+
+ @Test
+ public void testWaarpPassword() throws Exception {
+ DetectionUtils.setJunit(true);
+ int step = 0;
+ System.out.println("Step " + step++);
+ {
+ String[] args = {
+ };
+ WaarpPassword.main(args);
+ }
+ Thread.sleep(5);
+ // using DES
+ System.out.println("Step " + step++);
+ File keyFile = new File("/tmp/out.ggp");
+ keyFile.delete();
+ {
+ String[] args = {
+ "-clear",
+ "-des",
+ "-ko", "/tmp/out.ggp"
+ };
+ WaarpPassword.main(args);
+ assertTrue(keyFile.exists());
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ {
+ String[] args = {
+ "-clear",
+ "-ki", "/tmp/out.ggp"
+ };
+ WaarpPassword.main(args);
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ File pwd = new File("/tmp/pwd.ggp");
+ pwd.delete();
+ {
+ String[] args = {
+ "-clear",
+ "-ki", "/tmp/out.ggp",
+ "-po", "/tmp/pwd.ggp",
+ "-pwd", "pwd"
+ };
+ WaarpPassword.main(args);
+ assertTrue(pwd.exists());
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ {
+ String[] args = {
+ "-clear",
+ "-ki", "/tmp/out.ggp",
+ "-pi", "/tmp/pwd.ggp"
+ };
+ WaarpPassword.main(args);
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ String cpwd = WaarpStringUtils.readFile("/tmp/pwd.ggp");
+ {
+ String[] args = {
+ "-clear",
+ "-ki", "/tmp/out.ggp",
+ "-po", "/tmp/pwd.ggp",
+ "-cpwd", cpwd
+ };
+ WaarpPassword.main(args);
+ assertTrue(pwd.exists());
+ }
+ // Using BlowFish
+ keyFile.delete();
+ pwd.delete();
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+
+ {
+ String[] args = {
+ "-clear",
+ "-blf",
+ "-ko", "/tmp/out.ggp"
+ };
+ WaarpPassword.main(args);
+ assertTrue(keyFile.exists());
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ {
+ String[] args = {
+ "-clear",
+ "-blf",
+ "-ki", "/tmp/out.ggp"
+ };
+ WaarpPassword.main(args);
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ {
+ String[] args = {
+ "-clear",
+ "-blf",
+ "-ki", "/tmp/out.ggp",
+ "-po", "/tmp/pwd.ggp",
+ "-pwd", "pwd"
+ };
+ WaarpPassword.main(args);
+ assertTrue(pwd.exists());
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ {
+ String[] args = {
+ "-clear",
+ "-blf",
+ "-ki", "/tmp/out.ggp",
+ "-pi", "/tmp/pwd.ggp"
+ };
+ WaarpPassword.main(args);
+ }
+ Thread.sleep(5);
+ System.out.println("Step " + step++);
+ cpwd = WaarpStringUtils.readFile("/tmp/pwd.ggp");
+ {
+ String[] args = {
+ "-clear",
+ "-blf",
+ "-ki", "/tmp/out.ggp",
+ "-po", "/tmp/pwd.ggp",
+ "-cpwd", cpwd
+ };
+ WaarpPassword.main(args);
+ assertTrue(pwd.exists());
+ }
+ pwd.delete();
+ keyFile.delete();
+ }
+
+}
\ No newline at end of file