Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
0c2670b1
Commit
0c2670b1
authored
Apr 20, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for key
parent
940f4ca4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
282 additions
and
101 deletions
+282
-101
drip-api-json-client.jar
drip-tests/lib/drip-api-json-client.jar
+0
-0
pom.xml
drip-tests/pom.xml
+59
-8
ec2_test.properties
drip-tests/src/main/resources/ec2_test.properties
+2
-1
test.properties
drip-tests/src/main/resources/test.properties
+1
-0
KeyPairClient.java
...test/java/nl/uva/sne/drip/test/clients/KeyPairClient.java
+75
-0
RestClient.java
...rc/test/java/nl/uva/sne/drip/test/clients/RestClient.java
+72
-0
DRIPTest.java
.../src/test/java/nl/uva/sne/drip/test/manager/DRIPTest.java
+32
-17
TestCloudCredentialsController.java
...sne/drip/test/manager/TestCloudCredentialsController.java
+2
-34
TestKeysController.java
...java/nl/uva/sne/drip/test/manager/TestKeysController.java
+39
-41
No files found.
drip-tests/lib/drip-api-json-client.jar
0 → 100644
View file @
0c2670b1
File added
drip-tests/pom.xml
View file @
0c2670b1
...
@@ -8,7 +8,11 @@
...
@@ -8,7 +8,11 @@
</parent>
</parent>
<artifactId>
drip-tests
</artifactId>
<artifactId>
drip-tests
</artifactId>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<properties>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<!--<maven.test.skip>true</maven.test.skip>-->
</properties>
<dependencies>
<dependencies>
...
@@ -38,6 +42,28 @@
...
@@ -38,6 +42,28 @@
<scope>
test
</scope>
<scope>
test
</scope>
<type>
jar
</type>
<type>
jar
</type>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.2
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
org.glassfish.grizzly
</groupId>
<artifactId>
grizzly-framework
</artifactId>
<version>
2.3.28
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
org.glassfish.jersey.core
</groupId>
<artifactId>
jersey-client
</artifactId>
<version>
2.25.1
</version>
<scope>
test
</scope>
<type>
jar
</type>
</dependency>
<dependency>
<dependency>
<groupId>
javax
</groupId>
<groupId>
javax
</groupId>
<artifactId>
javaee-web-api
</artifactId>
<artifactId>
javaee-web-api
</artifactId>
...
@@ -50,22 +76,47 @@
...
@@ -50,22 +76,47 @@
<groupId>
nl.uva.sne.drip
</groupId>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip-api-json-client
</artifactId>
<artifactId>
drip-api-json-client
</artifactId>
<version>
1.0
</version>
<version>
1.0
</version>
<scope>
system
</scope>
<scope>
test
</scope>
<systemPath>
${basedir}/../docs/apidocs/drip-api-json-client.jar
</systemPath>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.8.6
</version>
<scope>
test
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-install-plugin
</artifactId>
<version>
2.5.2
</version>
<executions>
<execution>
<id>
install-external
</id>
<phase>
clean
</phase>
<configuration>
<file>
${basedir}/../docs/apidocs/drip-api-json-client.jar
</file>
<repositoryLayout>
default
</repositoryLayout>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip-api-json-client
</artifactId>
<version>
1.0
</version>
<packaging>
jar
</packaging>
<generatePom>
true
</generatePom>
</configuration>
<goals>
<goal>
install-file
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</build>
<properties>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
</properties>
</project>
</project>
\ No newline at end of file
drip-tests/src/main/resources/ec2_test.properties
View file @
0c2670b1
access.key.id
=
lferpoiewp
access.key.id
=
lferpoiewp
secret.key
=
erfiru
secret.key
=
erfiru
cloud.provider.name
=
ec2
cloud.provider.name
=
ec2
cloud.private.key.paths
=
/home/alogo/Virginia.pem,/home/alogo/California.pem
cloud.private.key.paths
=
/home/alogo/Downloads/DRIP/Virginia.pem,/home/alogo/Downloads/DRIP/California.pem
\ No newline at end of file
drip.host
=
http://localhost:8080/drip-api
\ No newline at end of file
drip-tests/src/main/resources/test.properties
0 → 100644
View file @
0c2670b1
test.property.files
=
ec2_test.properties
\ No newline at end of file
drip-tests/src/test/java/nl/uva/sne/drip/test/clients/KeyPairClient.java
0 → 100644
View file @
0c2670b1
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* 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.
*/
package
nl
.
uva
.
sne
.
drip
.
test
.
clients
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
java.io.IOException
;
import
java.net.URL
;
import
javax.ws.rs.client.Entity
;
import
javax.ws.rs.core.Response
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
/**
*
* @author S. Koulouzis
*/
public
class
KeyPairClient
extends
RestClient
{
private
static
final
String
PATH
=
"/user/v1.0/keys"
;
public
KeyPairClient
(
URL
host
)
{
super
(
host
);
}
public
Response
postKeyPair
(
KeyPair
pair
)
throws
JsonProcessingException
{
String
jsonInString
=
getMapper
().
writeValueAsString
(
pair
);
Entity
<
String
>
entity
=
Entity
.
json
(
jsonInString
);
// Entity<KeyPair> entity = Entity.entity(pair, "application/json");
return
getWebTarget
().
path
(
PATH
).
request
().
header
(
"Authorization"
,
"Basic dXNlcjoxMjM="
).
post
(
entity
);
}
public
String
getPostKeyPairResponse
(
Response
response
)
{
return
response
.
readEntity
(
String
.
class
);
}
public
Response
get
(
String
keyID
)
{
return
getWebTarget
().
path
(
PATH
).
path
(
keyID
).
request
().
header
(
"Authorization"
,
"Basic dXNlcjoxMjM="
).
get
();
}
public
KeyPair
getGetKeyPairResponse
(
Response
response
)
throws
IOException
{
String
json
=
response
.
readEntity
(
String
.
class
);
return
getMapper
().
readValue
(
json
,
KeyPair
.
class
);
}
public
Response
delete
(
String
keyID
)
{
return
getWebTarget
().
path
(
PATH
).
path
(
keyID
).
request
().
header
(
"Authorization"
,
"Basic dXNlcjoxMjM="
).
delete
();
}
}
drip-tests/src/test/java/nl/uva/sne/drip/test/clients/RestClient.java
0 → 100644
View file @
0c2670b1
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* 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.
*/
package
nl
.
uva
.
sne
.
drip
.
test
.
clients
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.net.URL
;
import
javax.net.ssl.SSLContext
;
import
javax.ws.rs.client.Client
;
import
javax.ws.rs.client.ClientBuilder
;
import
javax.ws.rs.client.WebTarget
;
import
org.glassfish.grizzly.ssl.SSLContextConfigurator
;
/**
*
* @author S. Koulouzis
*/
public
class
RestClient
{
private
final
Client
client
;
private
final
WebTarget
webTarget
;
private
final
ObjectMapper
mapper
;
public
RestClient
(
URL
host
)
{
this
.
client
=
createClient
();
this
.
webTarget
=
client
.
target
(
host
.
toString
());
this
.
mapper
=
new
ObjectMapper
();
}
private
Client
createClient
()
{
ClientBuilder
builder
=
ClientBuilder
.
newBuilder
();
SSLContextConfigurator
sslContextConfigurator
=
new
SSLContextConfigurator
();
SSLContext
sc
=
sslContextConfigurator
.
createSSLContext
(
true
);
builder
=
builder
.
sslContext
(
sc
);
builder
.
hostnameVerifier
(
new
javax
.
net
.
ssl
.
HostnameVerifier
()
{
public
boolean
verify
(
String
hostname
,
javax
.
net
.
ssl
.
SSLSession
sslSession
)
{
return
true
;
}
});
return
builder
.
build
();
}
/**
* @return the webTarget
*/
public
WebTarget
getWebTarget
()
{
return
webTarget
;
}
/**
* @return the mapper
*/
public
ObjectMapper
getMapper
()
{
return
mapper
;
}
}
drip-tests/src/test/java/nl/uva/sne/drip/test/manager/DRIPTest.java
View file @
0c2670b1
...
@@ -19,8 +19,10 @@ import java.io.File;
...
@@ -19,8 +19,10 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
...
@@ -30,6 +32,10 @@ import org.junit.After;
...
@@ -30,6 +32,10 @@ import org.junit.After;
import
org.junit.AfterClass
;
import
org.junit.AfterClass
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.apache.http.*
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.util.EntityUtils
;
/**
/**
*
*
...
@@ -37,22 +43,25 @@ import org.junit.BeforeClass;
...
@@ -37,22 +43,25 @@ import org.junit.BeforeClass;
*/
*/
public
class
DRIPTest
{
public
class
DRIPTest
{
private
static
List
<
String
>
PROPERTIES_FILE_PATHS
;
private
static
List
<
String
>
PROPERTIES_FILE_PATHS
=
new
ArrayList
<>()
;
public
static
List
<
Properties
>
propertiesList
=
new
ArrayList
<>();
public
static
List
<
Properties
>
propertiesList
=
new
ArrayList
<>();
public
static
final
String
ACCESS_KEY_ID_PROPPERTY_NAME
=
"access.key.id"
;
public
static
final
String
ACCESS_KEY_ID_PROPPERTY_NAME
=
"access.key.id"
;
static
String
CLOUD_PROPVIDER_PROPPERTY_NAME
=
"cloud.provider.name"
;
public
static
final
String
CLOUD_PROPVIDER_PROPPERTY_NAME
=
"cloud.provider.name"
;
static
String
SECRET_KEY_PROPERTY_NAME
=
"secret.key"
;
public
static
final
String
SECRET_KEY_PROPERTY_NAME
=
"secret.key"
;
static
String
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
=
"cloud.private.key.paths"
;
public
static
final
String
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
=
"cloud.private.key.paths"
;
public
static
final
String
DRIP_HOST_PROPERTY_NAME
=
"drip.host"
;
public
DRIPTest
()
{
public
static
final
String
DRIP_TEST_PROPERTY_FILES_PROPERTY_NAME
=
"test.property.files"
;
PROPERTIES_FILE_PATHS
=
new
ArrayList
<>();
}
@BeforeClass
@BeforeClass
public
static
void
setUpClass
()
{
public
static
void
setUpClass
()
{
try
(
InputStream
is
=
ClassLoader
.
getSystemResourceAsStream
(
"test.properties"
))
{
Properties
mainPropertyFile
=
new
Properties
();
mainPropertyFile
.
load
(
is
);
PROPERTIES_FILE_PATHS
=
Arrays
.
asList
(
mainPropertyFile
.
getProperty
(
DRIP_TEST_PROPERTY_FILES_PROPERTY_NAME
).
split
(
","
));
for
(
String
propFile
:
PROPERTIES_FILE_PATHS
)
{
for
(
String
propFile
:
PROPERTIES_FILE_PATHS
)
{
try
(
Reader
inStream
=
new
FileReader
(
new
File
(
propFile
)
))
{
try
(
InputStream
inStream
=
ClassLoader
.
getSystemResourceAsStream
(
propFile
))
{
Properties
prop
=
new
Properties
();
Properties
prop
=
new
Properties
();
prop
.
load
(
inStream
);
prop
.
load
(
inStream
);
propertiesList
.
add
(
prop
);
propertiesList
.
add
(
prop
);
...
@@ -62,6 +71,12 @@ public class DRIPTest {
...
@@ -62,6 +71,12 @@ public class DRIPTest {
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
DRIPTest
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
...
...
drip-tests/src/test/java/nl/uva/sne/drip/test/manager/TestCloudCredentialsController.java
View file @
0c2670b1
...
@@ -16,10 +16,7 @@
...
@@ -16,10 +16,7 @@
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -27,15 +24,6 @@ import java.util.Map;
...
@@ -27,15 +24,6 @@ import java.util.Map;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
javax.ws.rs.client.Entity
;
import
javax.ws.rs.client.Invocation
;
import
javax.ws.rs.core.Response
;
import
nl.uva.sne.drip.data.v1.external.CloudCredentials
;
import
nl.uva.sne.drip.data.v1.external.CloudCredentials
;
import
nl.uva.sne.drip.data.v1.external.Key
;
import
nl.uva.sne.drip.data.v1.external.Key
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
...
@@ -43,9 +31,6 @@ import nl.uva.sne.drip.data.v1.external.KeyType;
...
@@ -43,9 +31,6 @@ import nl.uva.sne.drip.data.v1.external.KeyType;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
*
*
...
@@ -53,18 +38,10 @@ import static org.junit.Assert.assertEquals;
...
@@ -53,18 +38,10 @@ import static org.junit.Assert.assertEquals;
*/
*/
public
class
TestCloudCredentialsController
extends
DRIPTest
{
public
class
TestCloudCredentialsController
extends
DRIPTest
{
@BeforeClass
public
static
void
setUpClass
()
{
}
@AfterClass
public
static
void
tearDownClass
()
{
}
@Test
@Test
public
void
testPOST_GETCloudCredentials
()
{
public
void
testPOST_GETCloudCredentials
()
{
for
(
Properties
p
:
DRIPTest
.
propertiesList
)
{
for
(
Properties
p
:
DRIPTest
.
propertiesList
)
{
String
[]
paths
=
DRIPTest
.
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
.
split
(
","
);
String
[]
paths
=
p
.
getProperty
(
DRIPTest
.
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
)
.
split
(
","
);
for
(
String
cloudPrivateKeyPath
:
paths
)
{
for
(
String
cloudPrivateKeyPath
:
paths
)
{
try
{
try
{
KeyPair
keyPair
=
new
KeyPair
();
KeyPair
keyPair
=
new
KeyPair
();
...
@@ -76,6 +53,7 @@ public class TestCloudCredentialsController extends DRIPTest {
...
@@ -76,6 +53,7 @@ public class TestCloudCredentialsController extends DRIPTest {
map
.
put
(
cloudPrivateKeyPath
,
cloudPrivateKeyPath
);
map
.
put
(
cloudPrivateKeyPath
,
cloudPrivateKeyPath
);
privateKey
.
setAttributes
(
map
);
privateKey
.
setAttributes
(
map
);
keyPair
.
setPrivateKey
(
privateKey
);
keyPair
.
setPrivateKey
(
privateKey
);
}
catch
(
IOException
ex
)
{
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
...
@@ -91,14 +69,4 @@ public class TestCloudCredentialsController extends DRIPTest {
...
@@ -91,14 +69,4 @@ public class TestCloudCredentialsController extends DRIPTest {
}
}
}
}
private
void
post
(
int
expected
)
{
// String payload = "{\"local-storage-id\" : \"" + storageId + "\"}";
// Entity<String> entity = Entity.entity(payload, "application/json");
// Response resp = getWebTarget().path(TRIGGER_PATH).path(lcmId).path("metadata").path(metadataId)
// .request().header(AUTH_USER_HEADER, "admin")
// .header(BasicAuthenticationManager.BASIC_AUTHENTICATION_HEADER, basicAuthTokenAdmin)
// .post(entity);
// assertEquals(expected, resp.getStatus());
}
}
}
drip-tests/src/test/java/nl/uva/sne/drip/test/manager/TestKeysController.java
View file @
0c2670b1
...
@@ -15,15 +15,25 @@
...
@@ -15,15 +15,25 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
package
nl
.
uva
.
sne
.
drip
.
test
.
manager
;
import
nl.uva.sne.drip.test.clients.KeyPairClient
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
javax.ws.rs.core.Response
;
import
nl.uva.sne.drip.data.v1.external.CloudCredentials
;
import
nl.uva.sne.drip.data.v1.external.Key
;
import
nl.uva.sne.drip.data.v1.external.Key
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
import
nl.uva.sne.drip.data.v1.external.KeyPair
;
import
nl.uva.sne.drip.data.v1.external.KeyType
;
import
nl.uva.sne.drip.data.v1.external.KeyType
;
import
static
nl
.
uva
.
sne
.
drip
.
test
.
manager
.
DRIPTest
.
ACCESS_KEY_ID_PROPPERTY_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
test
.
manager
.
DRIPTest
.
CLOUD_PROPVIDER_PROPPERTY_NAME
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -35,43 +45,34 @@ import static org.junit.Assert.*;
...
@@ -35,43 +45,34 @@ import static org.junit.Assert.*;
/**
/**
*
*
* @author
alogo
* @author
S. Koulouzis
*/
*/
public
class
TestKeysController
extends
DRIPTest
{
public
class
TestKeysController
extends
DRIPTest
{
public
TestKeysController
()
{
}
@BeforeClass
public
static
void
setUpClass
()
{
}
@AfterClass
public
static
void
tearDownClass
()
{
}
@Before
public
void
setUp
()
{
}
@After
public
void
tearDown
()
{
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
@Test
public
void
test_POST_GETCoudKeys
()
{
public
void
test_POST_GET_DELETECoudKeys
()
throws
MalformedURLException
{
String
[]
paths
=
DRIPTest
.
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
.
split
(
","
);
for
(
Properties
p
:
DRIPTest
.
propertiesList
)
{
String
[]
paths
=
p
.
getProperty
(
DRIPTest
.
CLOUD_PRIVATE_KEY_PATHS_PROPERTY_NAME
).
split
(
","
);
KeyPairClient
client
=
new
KeyPairClient
(
new
URL
(
p
.
getProperty
(
DRIPTest
.
DRIP_HOST_PROPERTY_NAME
)));
for
(
String
cloudPrivateKeyPath
:
paths
)
{
for
(
String
cloudPrivateKeyPath
:
paths
)
{
try
{
try
{
KeyPair
keyPair
=
new
KeyPair
();
KeyPair
keyPair
=
new
KeyPair
();
Key
privateKey
=
createPrivateCloudKey
(
cloudPrivateKeyPath
);
Key
privateKey
=
createPrivateCloudKey
(
cloudPrivateKeyPath
);
keyPair
.
setPrivateKey
(
privateKey
);
keyPair
.
setPrivateKey
(
privateKey
);
post
(
keyPair
,
200
);
Response
response
=
client
.
postKeyPair
(
keyPair
);
assertEquals
(
200
,
response
.
getStatus
());
String
keyID
=
client
.
getPostKeyPairResponse
(
response
);
assertNotNull
(
keyID
);
response
=
client
.
get
(
keyID
);
assertEquals
(
200
,
response
.
getStatus
());
KeyPair
returnedPair
=
client
.
getGetKeyPairResponse
(
response
);
assertNotNull
(
returnedPair
);
assertEquals
(
keyID
,
returnedPair
.
getId
());
assertNotNull
(
returnedPair
.
getPrivateKey
());
response
=
client
.
delete
(
keyID
);
assertEquals
(
200
,
response
.
getStatus
());
}
catch
(
IOException
ex
)
{
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
TestCloudCredentialsController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
...
@@ -79,18 +80,15 @@ public class TestKeysController extends DRIPTest {
...
@@ -79,18 +80,15 @@ public class TestKeysController extends DRIPTest {
}
}
}
}
private
void
post
(
KeyPair
keyPair
,
int
expected
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
//To change body of generated methods, choose Tools | Templates.
}
}
private
Key
createPrivateCloudKey
(
String
cloudPrivateKeyPath
)
throws
IOException
{
private
Key
createPrivateCloudKey
(
String
cloudPrivateKeyPath
)
throws
IOException
{
Key
privateKey
=
new
Key
();
Key
privateKey
=
new
Key
();
privateKey
.
setName
(
File
Utils
.
readFileToString
(
new
File
(
cloudPrivateKeyPath
),
"UTF-8"
));
privateKey
.
setName
(
File
nameUtils
.
getBaseName
(
cloudPrivateKeyPath
));
privateKey
.
setKey
(
File
nameUtils
.
getBaseName
(
cloudPrivateKeyPath
));
privateKey
.
setKey
(
File
Utils
.
readFileToString
(
new
File
(
cloudPrivateKeyPath
),
"UTF-8"
));
privateKey
.
setType
(
KeyType
.
PRIVATE
);
privateKey
.
setType
(
KeyType
.
PRIVATE
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"
attribute"
,
"value"
);
map
.
put
(
"
domain_name"
,
FilenameUtils
.
getBaseName
(
cloudPrivateKeyPath
)
);
privateKey
.
setAttributes
(
map
);
privateKey
.
setAttributes
(
map
);
return
privateKey
;
return
privateKey
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment