adding license

This commit is contained in:
Dave
2015-07-04 15:36:56 +02:00
parent a0321aa45a
commit 6176bede43
7 changed files with 134 additions and 14 deletions

View File

@@ -1,3 +1,20 @@
/*
* Copyright 2014 David Horscroft
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
* no- functionality.
*/
package nodash.test;
import static org.junit.Assert.*;

View File

@@ -1,3 +1,20 @@
/*
* Copyright 2014 David Horscroft
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
* no- functionality.
*/
package nodash.test;
import org.junit.runner.RunWith;

View File

@@ -1,3 +1,20 @@
/*
* Copyright 2014 David Horscroft
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
* no- functionality.
*/
package nodash.test;
import static org.junit.Assert.*;

View File

@@ -1,3 +1,20 @@
/*
* Copyright 2014 David Horscroft
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
* no- functionality.
*/
package nodash.test;
import static org.junit.Assert.*;
@@ -14,11 +31,11 @@ import org.apache.commons.codec.binary.Base64;
import org.junit.Test;
public class NoUserTest {
@Test
public void testNoUser() {
NoUser user = new NoUser();
assertNotNull(user.getNoActions());
assertEquals(user.getNoActions().size(), 0);
assertNotNull(user.getRsaPublicKey());
@@ -31,12 +48,12 @@ public class NoUserTest {
public void testCreateFile() {
NoUser user = new NoUser();
byte[] file = user.createFile("password".toCharArray());
assertNotNull(file);
assertTrue(file.length > 0);
byte[] secondFile = user.createFile("password".toCharArray());
assertFalse(Arrays.equals(file, secondFile));
}
@@ -44,45 +61,46 @@ public class NoUserTest {
public void testCreateHash() {
NoUser user = new NoUser();
byte[] hash = user.createHash();
assertNotNull(hash);
assertEquals(hash.length, 64);
byte[] secondHash = user.createHash();
assertTrue(Arrays.equals(hash, secondHash));
}
@Test
public void testCreateHashString() {
NoUser user = new NoUser();
byte[] hash = user.createHash();
String hashString = user.createHashString();
assertEquals(Base64.encodeBase64URLSafeString(hash), hashString);
}
@Test
public void testCreateUserFromFile() throws IllegalBlockSizeException, BadPaddingException, ClassNotFoundException, IOException {
public void testCreateUserFromFile() throws IllegalBlockSizeException, BadPaddingException,
ClassNotFoundException, IOException {
NoUser user = new NoUser();
final byte[] originalFile = user.createFile("password".toCharArray());
byte[] file = Arrays.copyOf(originalFile, originalFile.length);
byte[] hash = user.createHash();
String hashString = user.createHashString();
user = null;
try {
user = NoUser.createUserFromFile(file, "wrongpassword".toCharArray());
fail("Should have thrown an error when given wrong password.");
} catch (BadPaddingException e) {
// Do nothing, correct
}
file = Arrays.copyOf(originalFile, originalFile.length);
user = NoUser.createUserFromFile(file, "password".toCharArray());
assertTrue(Arrays.equals(hash, user.createHash()));
assertEquals(hashString, user.createHashString());
file = Arrays.copyOf(originalFile, originalFile.length);
try {
NoUser.createUserFromFile(file, null);

View File

@@ -1,3 +1,20 @@
/*
* Copyright 2014 David Horscroft
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
* no- functionality.
*/
package nodash.test;
import static org.junit.Assert.*;