-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
237 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
teamcity-azure-plugin-server/src/test/java/jetbrains/buildServer/clouds/TestDeserialize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* | ||
* * Copyright 2000-2014 JetBrains s.r.o. | ||
* * | ||
* * 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 jetbrains.buildServer.clouds; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
import java.io.IOException; | ||
import java.lang.reflect.Type; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import jetbrains.buildServer.clouds.azure.AzureCloudImageDetails; | ||
import jetbrains.buildServer.clouds.base.types.CloneBehaviour; | ||
import jetbrains.buildServer.serverSide.crypt.EncryptUtil; | ||
import jetbrains.buildServer.serverSide.crypt.RSACipher; | ||
import org.apache.commons.codec.DecoderException; | ||
import org.apache.commons.codec.binary.Hex; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author Sergey.Pak | ||
* Date: 10/20/2014 | ||
* Time: 4:03 PM | ||
*/ | ||
|
||
@Test | ||
public class TestDeserialize { | ||
|
||
public void testDeserialize() throws IOException, DecoderException { | ||
|
||
String jsondata = "{\"data\":\"beta\"}"; | ||
Gson gson = new Gson(); | ||
Map<String, String> map = new HashMap<String, String>(); | ||
map = gson.fromJson(jsondata, map.getClass()); | ||
System.out.println(); | ||
|
||
final String data = | ||
"aa7214cd622cf7e6fa086bd0b4e7bb0fcc61b320901f97c17d77c9f7e0df30b0f60bbb19fe72e5a93fda4aa6288bc0f3b1ed2a4badf985ac6677edf0f58d31d415c70d46163c6843a245fd4c90ff65fb381c916d2476c0759ca0f87316bc6b95ec4be4054a114f86ab16297850c6665b9548057b770167aaebe71f0a916146a6"; | ||
final String pw = "qwerty"; | ||
final String s = RSACipher.decryptData(RSACipher.encryptData(pw)); | ||
System.out.println(s); | ||
System.out.println(data); | ||
System.out.println(RSACipher.encryptData(pw)); | ||
|
||
System.out.println(RSACipher.getHexEncodedPublicKey()); | ||
System.out.println(RSACipher.encryptDataForWeb(pw)); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
teamcity-azure-plugin-server/src/test/java/jetbrains/buildServer/clouds/base/FakeModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* | ||
* * Copyright 2000-2014 JetBrains s.r.o. | ||
* * | ||
* * 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 jetbrains.buildServer.clouds.base; | ||
|
||
import java.util.Map; | ||
import jetbrains.buildServer.clouds.base.connector.AbstractInstance; | ||
|
||
/** | ||
* @author Sergey.Pak | ||
* Date: 10/27/2014 | ||
* Time: 3:57 PM | ||
*/ | ||
public class FakeModel { | ||
private static final FakeModel instance = new FakeModel(); | ||
|
||
public static FakeModel instance(){ | ||
return instance; | ||
} | ||
|
||
public Map<String, AbstractInstance> getInstances(){ | ||
return null; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...in-server/src/test/java/jetbrains/buildServer/clouds/base/connector/FakeApiConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* | ||
* * Copyright 2000-2014 JetBrains s.r.o. | ||
* * | ||
* * 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 jetbrains.buildServer.clouds.base.connector; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import jetbrains.buildServer.clouds.CloudException; | ||
import jetbrains.buildServer.clouds.InstanceStatus; | ||
import jetbrains.buildServer.clouds.base.AbstractCloudImage; | ||
import jetbrains.buildServer.clouds.base.AbstractCloudInstance; | ||
import jetbrains.buildServer.clouds.base.errors.TypedCloudErrorInfo; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* @author Sergey.Pak | ||
* Date: 10/27/2014 | ||
* Time: 3:53 PM | ||
*/ | ||
public class FakeApiConnector implements CloudApiConnector { | ||
|
||
public InstanceStatus getInstanceStatus(@NotNull final AbstractCloudInstance instance) { | ||
return null; | ||
} | ||
|
||
public Map<String, ? extends AbstractInstance> listImageInstances(@NotNull final AbstractCloudImage image) throws CloudException { | ||
return null; | ||
} | ||
|
||
public Collection<TypedCloudErrorInfo> checkImage(@NotNull final AbstractCloudImage image) { | ||
return null; | ||
} | ||
|
||
public Collection<TypedCloudErrorInfo> checkInstance(@NotNull final AbstractCloudInstance instance) { | ||
return null; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...server/src/test/java/jetbrains/buildServer/clouds/base/tasks/UpdateInstancesTaskTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* | ||
* * Copyright 2000-2014 JetBrains s.r.o. | ||
* * | ||
* * 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 jetbrains.buildServer.clouds.base.tasks; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import jetbrains.buildServer.clouds.CloudException; | ||
import jetbrains.buildServer.clouds.InstanceStatus; | ||
import jetbrains.buildServer.clouds.base.AbstractCloudClient; | ||
import jetbrains.buildServer.clouds.base.AbstractCloudImage; | ||
import jetbrains.buildServer.clouds.base.AbstractCloudInstance; | ||
import jetbrains.buildServer.clouds.base.connector.AbstractInstance; | ||
import jetbrains.buildServer.clouds.base.connector.CloudApiConnector; | ||
import jetbrains.buildServer.clouds.base.errors.TypedCloudErrorInfo; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* @author Sergey.Pak | ||
* Date: 10/27/2014 | ||
* Time: 3:52 PM | ||
*/ | ||
@Test | ||
public class UpdateInstancesTaskTest { | ||
|
||
private UpdateInstancesTask myTask; | ||
private CloudApiConnector myApiConnector; | ||
private AbstractCloudClient myClient; | ||
|
||
@BeforeMethod | ||
public void setUp(){ | ||
myApiConnector = new CloudApiConnector() { | ||
public InstanceStatus getInstanceStatus(@NotNull final AbstractCloudInstance instance) { | ||
return null; | ||
} | ||
|
||
public Map<String, ? extends AbstractInstance> listImageInstances(@NotNull final AbstractCloudImage image) throws CloudException { | ||
return null; | ||
} | ||
|
||
public Collection<TypedCloudErrorInfo> checkImage(@NotNull final AbstractCloudImage image) { | ||
return null; | ||
} | ||
|
||
public Collection<TypedCloudErrorInfo> checkInstance(@NotNull final AbstractCloudInstance instance) { | ||
return null; | ||
} | ||
}; | ||
myTask = new UpdateInstancesTask(myApiConnector, myClient); | ||
} | ||
|
||
public void test(){ | ||
} | ||
|
||
|
||
@AfterMethod | ||
public void tearDown(){ | ||
|
||
} | ||
|
||
} |