diff options
author | Nils Schwabe | 2014-04-25 16:20:50 +0200 |
---|---|---|
committer | Nils Schwabe | 2014-04-25 16:20:50 +0200 |
commit | b9878eda35e354d16ce732a57b7fabebb46c1a46 (patch) | |
tree | c0d9c7ad51025affb1480e676f3f37841c3bcd7b /src/test/java/org/openslx/imagemaster | |
parent | Merge branch 'master' of git.openslx.org:bwlp/masterserver (diff) | |
download | masterserver-b9878eda35e354d16ce732a57b7fabebb46c1a46.tar.gz masterserver-b9878eda35e354d16ce732a57b7fabebb46c1a46.tar.xz masterserver-b9878eda35e354d16ce732a57b7fabebb46c1a46.zip |
Add remove image from process list (when user gets deleted after timeout)
Fix problems with timeout user deleting
Diffstat (limited to 'src/test/java/org/openslx/imagemaster')
-rw-r--r-- | src/test/java/org/openslx/imagemaster/ServerTest.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/test/java/org/openslx/imagemaster/ServerTest.java b/src/test/java/org/openslx/imagemaster/ServerTest.java index c791f52..bb81432 100644 --- a/src/test/java/org/openslx/imagemaster/ServerTest.java +++ b/src/test/java/org/openslx/imagemaster/ServerTest.java @@ -1,5 +1,6 @@ package org.openslx.imagemaster; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -7,17 +8,24 @@ import java.net.ConnectException; import java.net.SocketException; import java.nio.ByteBuffer; import java.security.InvalidKeyException; +import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.Date; import java.util.UUID; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; + import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; +import org.apache.commons.net.ftp.FTPSClient; import org.apache.thrift.TException; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; @@ -111,8 +119,8 @@ public class ServerTest extends TestCase int version = 1; String imageName = "maschine.vmkd"; UUID uuid = UUID.randomUUID(); - int imageCreateTime = (int)new Date().getTime(); - int imageUpdateTime = imageCreateTime; + long imageCreateTime = System.currentTimeMillis(); + long imageUpdateTime = imageCreateTime; String imageOwner = "ns202"; String contentOperatingSystem = "win7"; boolean statusIsValid = true; @@ -124,12 +132,23 @@ public class ServerTest extends TestCase imageCreateTime, imageUpdateTime, imageOwner, contentOperatingSystem, statusIsValid, statusIsDeleted, imageShortDescrption, imageLongDescription ); - System.out.println( "Created imageData" ); + System.out.println( "Created imageData..." ); FtpCredentials ftpCredentials = client.submitImage( data.sessionId, imageData ); System.out.println( "Got FTP credentials. User: " + ftpCredentials.username + ", password: " + ftpCredentials.password ); - FTPClient FtpClient = new FTPClient(); + FTPSClient FtpClient = new FTPSClient( "SSL" ); + System.out.println("Created new ftpsclient..."); + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( "JKS" ); + KeyStore keystore = KeyStore.getInstance( "JKS" ); + keystore.load( new FileInputStream( new File( "./config/keystore.jks" ) ), "password".toCharArray() ); + System.out.println("Loaded keystore.."); + trustManagerFactory.init( keystore ); + TrustManager trustManager = trustManagerFactory.getTrustManagers()[0]; + FtpClient.setTrustManager(trustManager); + + System.out.println("Trying to connect..."); + String host = "localhost"; int port = 2221; String user = ftpCredentials.username; |