Restoring key-related unit/integration tests
The recent GATKReport commit accidentally clobbered a few tests -- this restores them.
This commit is contained in:
parent
42ace8bf7b
commit
5d6a686474
|
|
@ -27,9 +27,10 @@ package org.broadinstitute.sting.utils.crypt;
|
||||||
import org.broadinstitute.sting.BaseTest;
|
import org.broadinstitute.sting.BaseTest;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.testng.Assert;
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
import org.testng.Assert;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
@ -40,7 +41,6 @@ import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Test(enabled = false)
|
|
||||||
public class CryptUtilsUnitTest extends BaseTest {
|
public class CryptUtilsUnitTest extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -65,11 +65,21 @@ public class CryptUtilsUnitTest extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGATKMasterKeyPairMutualDecryption() {
|
public void testGATKMasterKeyPairMutualDecryption() {
|
||||||
|
if ( gatkPrivateKeyExistsButReadPermissionDenied() ) {
|
||||||
|
throw new SkipException(String.format("Skipping test %s because we do not have permission to read the GATK private key",
|
||||||
|
"testGATKMasterKeyPairMutualDecryption"));
|
||||||
|
}
|
||||||
|
|
||||||
Assert.assertTrue(CryptUtils.keysDecryptEachOther(CryptUtils.loadGATKMasterPrivateKey(), CryptUtils.loadGATKMasterPublicKey()));
|
Assert.assertTrue(CryptUtils.keysDecryptEachOther(CryptUtils.loadGATKMasterPrivateKey(), CryptUtils.loadGATKMasterPublicKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGATKMasterPrivateKeyWithDistributedPublicKeyMutualDecryption() {
|
public void testGATKMasterPrivateKeyWithDistributedPublicKeyMutualDecryption() {
|
||||||
|
if ( gatkPrivateKeyExistsButReadPermissionDenied() ) {
|
||||||
|
throw new SkipException(String.format("Skipping test %s because we do not have permission to read the GATK private key",
|
||||||
|
"testGATKMasterPrivateKeyWithDistributedPublicKeyMutualDecryption"));
|
||||||
|
}
|
||||||
|
|
||||||
Assert.assertTrue(CryptUtils.keysDecryptEachOther(CryptUtils.loadGATKMasterPrivateKey(), CryptUtils.loadGATKDistributedPublicKey()));
|
Assert.assertTrue(CryptUtils.keysDecryptEachOther(CryptUtils.loadGATKMasterPrivateKey(), CryptUtils.loadGATKDistributedPublicKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,6 +167,11 @@ public class CryptUtilsUnitTest extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadGATKMasterPrivateKey() {
|
public void testLoadGATKMasterPrivateKey() {
|
||||||
|
if ( gatkPrivateKeyExistsButReadPermissionDenied() ) {
|
||||||
|
throw new SkipException(String.format("Skipping test %s because we do not have permission to read the GATK private key",
|
||||||
|
"testLoadGATKMasterPrivateKey"));
|
||||||
|
}
|
||||||
|
|
||||||
PrivateKey gatkMasterPrivateKey = CryptUtils.loadGATKMasterPrivateKey();
|
PrivateKey gatkMasterPrivateKey = CryptUtils.loadGATKMasterPrivateKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,4 +190,9 @@ public class CryptUtilsUnitTest extends BaseTest {
|
||||||
Assert.assertEquals(originalKey.getAlgorithm(), keyFromDisk.getAlgorithm());
|
Assert.assertEquals(originalKey.getAlgorithm(), keyFromDisk.getAlgorithm());
|
||||||
Assert.assertEquals(originalKey.getFormat(), keyFromDisk.getFormat());
|
Assert.assertEquals(originalKey.getFormat(), keyFromDisk.getFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean gatkPrivateKeyExistsButReadPermissionDenied() {
|
||||||
|
File gatkPrivateKey = new File(CryptUtils.GATK_MASTER_PRIVATE_KEY_FILE);
|
||||||
|
return gatkPrivateKey.exists() && ! gatkPrivateKey.canRead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Test(enabled = false)
|
|
||||||
public class GATKKeyIntegrationTest extends WalkerTest {
|
public class GATKKeyIntegrationTest extends WalkerTest {
|
||||||
|
|
||||||
public static final String BASE_COMMAND = String.format("-T PrintReads -R %s -I %s -o %%s",
|
public static final String BASE_COMMAND = String.format("-T PrintReads -R %s -I %s -o %%s",
|
||||||
|
|
|
||||||
|
|
@ -27,19 +27,24 @@ package org.broadinstitute.sting.utils.crypt;
|
||||||
import org.broadinstitute.sting.BaseTest;
|
import org.broadinstitute.sting.BaseTest;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.testng.Assert;
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
import org.testng.Assert;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
|
||||||
@Test(enabled = false)
|
|
||||||
public class GATKKeyUnitTest extends BaseTest {
|
public class GATKKeyUnitTest extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateGATKKeyUsingMasterKeyPair() {
|
public void testCreateGATKKeyUsingMasterKeyPair() {
|
||||||
|
if ( gatkPrivateKeyExistsButReadPermissionDenied() ) {
|
||||||
|
throw new SkipException(String.format("Skipping test %s because we do not have permission to read the GATK private key",
|
||||||
|
"testCreateGATKKeyUsingMasterKeyPair"));
|
||||||
|
}
|
||||||
|
|
||||||
PrivateKey masterPrivateKey = CryptUtils.loadGATKMasterPrivateKey();
|
PrivateKey masterPrivateKey = CryptUtils.loadGATKMasterPrivateKey();
|
||||||
PublicKey masterPublicKey = CryptUtils.loadGATKMasterPublicKey();
|
PublicKey masterPublicKey = CryptUtils.loadGATKMasterPublicKey();
|
||||||
|
|
||||||
|
|
@ -50,6 +55,11 @@ public class GATKKeyUnitTest extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateGATKKeyUsingMasterPrivateKeyAndDistributedPublicKey() {
|
public void testCreateGATKKeyUsingMasterPrivateKeyAndDistributedPublicKey() {
|
||||||
|
if ( gatkPrivateKeyExistsButReadPermissionDenied() ) {
|
||||||
|
throw new SkipException(String.format("Skipping test %s because we do not have permission to read the GATK private key",
|
||||||
|
"testCreateGATKKeyUsingMasterPrivateKeyAndDistributedPublicKey"));
|
||||||
|
}
|
||||||
|
|
||||||
PrivateKey masterPrivateKey = CryptUtils.loadGATKMasterPrivateKey();
|
PrivateKey masterPrivateKey = CryptUtils.loadGATKMasterPrivateKey();
|
||||||
PublicKey distributedPublicKey = CryptUtils.loadGATKDistributedPublicKey();
|
PublicKey distributedPublicKey = CryptUtils.loadGATKDistributedPublicKey();
|
||||||
|
|
||||||
|
|
@ -83,8 +93,7 @@ public class GATKKeyUnitTest extends BaseTest {
|
||||||
KeyPair keyPair = CryptUtils.generateKeyPair();
|
KeyPair keyPair = CryptUtils.generateKeyPair();
|
||||||
|
|
||||||
// Email addresses cannot contain the NUL byte, since it's used as a sectional delimiter in the key file:
|
// Email addresses cannot contain the NUL byte, since it's used as a sectional delimiter in the key file:
|
||||||
GATKKey key = new GATKKey(CryptUtils.loadGATKMasterPrivateKey(), CryptUtils.loadGATKDistributedPublicKey(),
|
GATKKey key = new GATKKey(keyPair.getPrivate(), keyPair.getPublic(), emailAddressWithNulByte);
|
||||||
emailAddressWithNulByte);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -111,4 +120,9 @@ public class GATKKeyUnitTest extends BaseTest {
|
||||||
|
|
||||||
GATKKey key = new GATKKey(CryptUtils.loadGATKDistributedPublicKey(), nonExistentFile);
|
GATKKey key = new GATKKey(CryptUtils.loadGATKDistributedPublicKey(), nonExistentFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean gatkPrivateKeyExistsButReadPermissionDenied() {
|
||||||
|
File gatkPrivateKey = new File(CryptUtils.GATK_MASTER_PRIVATE_KEY_FILE);
|
||||||
|
return gatkPrivateKey.exists() && ! gatkPrivateKey.canRead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue