Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Add Junit to v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericBregier committed Jul 22, 2019
1 parent c052da6 commit 1bfb48f
Show file tree
Hide file tree
Showing 5 changed files with 260 additions and 3 deletions.
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
#################
Expand Down Expand Up @@ -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

12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<artifactId>WaarpPassword</artifactId>
<packaging>jar</packaging>
<name>Waarp Password Management GUI and Console</name>
<version>3.0.7</version>
<version>3.1.0</version>
<description>Waarp Password Management GUI and Console</description>
<url>http://waarp.github.com/WaarpPassword</url>
<inceptionYear>2009</inceptionYear>
Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpCommon</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -59,6 +59,12 @@
<version>1.2.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -86,7 +92,7 @@
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecations>true</showDeprecations>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/waarp/uip/WaarpPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -77,19 +78,28 @@ 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) {
System.err.println("Password to crypt:");
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);
Expand All @@ -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);
Expand Down
Empty file added src/test/java/.gitkeep
Empty file.
170 changes: 170 additions & 0 deletions src/test/java/org/waarp/uip/WaarpPasswordTest.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
******************************************************************************/

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();
}

}

0 comments on commit 1bfb48f

Please sign in to comment.