Skip to content

Commit

Permalink
created new unit test class for tests with KeePassJava2
Browse files Browse the repository at this point in the history
  • Loading branch information
astrapi69 committed Aug 22, 2023
1 parent 8bead6b commit a0c706c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ resourceViewmodelVersion=6
jobjClonerVersion=2
lGoodDatePickerVersion=11.2.1
autoBrowserVersion=2.0.6
keePassJava2Version=2.1.4
##############################
# test dependencies versions #
##############################
keePassJava2Version=2.1.4
testObjectVersion=7.2
junitJupiterExtensionsVersion=1.1
assertjSwingVersion=3.17.1
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
implementation("io.github.astrapi69:tree-api:$treeApiVersion")
implementation("io.github.astrapi69:jobj-cloner:$jobjClonerVersion")
implementation("org.kquiet:auto-browser:$autoBrowserVersion")
implementation("org.linguafranca.pwdb:KeePassJava2:$keePassJava2Version")
testImplementation("org.linguafranca.pwdb:KeePassJava2:$keePassJava2Version")


testImplementation("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* The MIT License
*
* Copyright (C) 2015 Asterios Raptis
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package io.github.astrapi69.mystic.crypt.keepass2;

import java.io.InputStream;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.linguafranca.pwdb.Database;
import org.linguafranca.pwdb.Entry;
import org.linguafranca.pwdb.Group;
import org.linguafranca.pwdb.kdbx.KdbxCreds;
import org.linguafranca.pwdb.kdbx.simple.SimpleDatabase;

public class KeePass2Test
{


@Test
public void testKeePass2() throws Exception {
KdbxCreds credentials = new KdbxCreds("foo-secret-bar-1969-?".getBytes());
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("test-db.kdbx");
Database database = SimpleDatabase.load(credentials, inputStream);
Group rootGroup = database.getRootGroup();
List groups = rootGroup.getGroups();
List entries = rootGroup.getEntries();
if(!entries.isEmpty()) {
Entry o = (Entry) entries.get(0);
System.out.println(o);
}
}

}
Binary file added src/test/resources/test-db.kdbx
Binary file not shown.

0 comments on commit a0c706c

Please sign in to comment.