summaryrefslogtreecommitdiff
path: root/server/Test
diff options
context:
space:
mode:
authorroot <root@kabir-PC>2016-03-23 11:31:51 +0100
committerroot <root@kabir-PC>2016-03-23 11:31:51 +0100
commita26989103d70fb0dd3ff6834de107cae246778c3 (patch)
tree0f243c83b790ffb57f19261fc2a509131f6776ce /server/Test
parent1342db60283cb61a1c3810993575d35b9fb33ac0 (diff)
parent6e78d76f887d1149ea85bfb06db7ee7ad7435f5a (diff)
Merge branch 'develop' of https://github.com/manzerbredes/istic-openstack into develop
Diffstat (limited to 'server/Test')
-rwxr-xr-xserver/Test/AppTestClass.php26
-rw-r--r--server/Test/imageTests.php88
2 files changed, 47 insertions, 67 deletions
diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php
index 4d7cab5..e1631c5 100755
--- a/server/Test/AppTestClass.php
+++ b/server/Test/AppTestClass.php
@@ -1,6 +1,12 @@
<?php
include_once("../core/Plugin_Api.php");
include_once("../core/LibOverride/genTokenOptions.php");
+include_once("../core/ErrorManagement.php");
+
+use OpenCloud\Common\Error\BadResponseError;
+use OpenCloud\Common\Error\BaseError;
+use OpenCloud\Common\Error\NotImplementedError;
+use OpenCloud\Common\Error\UserInputError;
class AppTest{
@@ -10,6 +16,7 @@ class AppTest{
protected $tokenClass;
protected $tokenPost;
protected $output;
+ protected $errorClass;
public function __construct($args){
@@ -19,6 +26,9 @@ class AppTest{
$this->pluginsApi = plugin_api::getInstance();
$this->errorClass = new errorManagement($this);
$this->output = array();
+
+ $this->errorClass = new errorManagement($this);
+
$this->postParams = $_POST;
}
@@ -79,10 +89,16 @@ class AppTest{
}
public function getPostParam($name){
-
+
return $this->postParams[$name];
}
+
+ public function setPostParam($name, $value){
+
+ $this->postParams[$name] = $value;
+
+ }
public function setOutput($key, $out){
@@ -94,4 +110,12 @@ class AppTest{
return json_encode($this->output);
}
+
+ public function getErrorInstance(){
+
+ return $this->errorClass;
+
+ }
}
+
+
diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php
index 94ff7b6..d184d44 100644
--- a/server/Test/imageTests.php
+++ b/server/Test/imageTests.php
@@ -1,35 +1,6 @@
<?php
-require '../vendor/autoload.php';
-include('/istic-openstack/server/init.php');
-
-/*
-$options = Array();
-$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
-$options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"]));
-$options["authUrl"] = "http://148.60.11.31:5000/v3";
-
-$openstack = new OpenStack\OpenStack($options);
-
-//$identity = $openstack->identityV3();
-//var_dump($identity);
-// Since usernames will not be unique across an entire OpenStack installation,
-// when authenticating with them you must also provide your domain ID. You do
-// not have to do this if you authenticate with a user ID.
-/*$token = $identity->generateToken([
- 'user' => [
- 'name' => 'admin',
- 'password' => 'ae5or6cn',
- 'domain' => [
- 'id' => 'Default'
- ]
- ]
- ]);
- */
-//$compute = $openstack->computeV2(["region" => "RegionOne"]);
-//$image= $openstack->imagesV2(["region" => "RegionOne"]);
-//var_dump($compute->client);
-//$servers = $compute->listServers(true);
-echo 'toto';
+include('InitTest.php');
+include_once("../core/Image.php");
$image = new Image($App);
@@ -43,53 +14,38 @@ $opt['minDisk'] = 1;
$opt['protected'] = false;
$opt['minRam'] = 10;
-//$new_image = $image->create_image($opt);
+//$App->setPostParam('id', 'sdfihlus154dfhj');
+//$err = $image->action("createImage");
//Liste des images
-$images = $image->list_images();
+$image->action("listImage");
+$im = $App->show();
+$images = json_decode($im, true)["Images"];
+$recup;
echo "Images présentes :";
echo "</br>";
-
foreach($images as $i){
- echo $i->name;
- if($i->name == "Test"){
- $id_image = $i->id;
- $list = $i->tags;
- echo $i->status;
- }
+ $recup = $i;
+ echo $recup['name'];
echo "</br>";
-}
+ //echo $recup['id'];
+ }
echo "</br>";
+echo "Erreur capturée: ";
+echo "</br>";
+
+/*
+$App->setPostParam('id', 354);
+$err = $image->action("deleteImage");
+$temp = $App->show();
+$ret = json_decode($temp, true)["Images"];
+echo $ret['id'];
+*/
-if(isset($list)){
- foreach ($list as $l) {
- echo $l;
- echo "</br>";
- }
-}
-
-// Détails Image
-//$details = $image->image_details($id_image);
-
-//$image->delete_image('123456');
-
-//$image->desactivate_image($id_image);
-//$image->reactivate_image($id_image);
-
-//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
-//$image->upload_image($id_image, $file_name);
-//$image->download_image($id_image);
-/*
-$opt_update = Array();
-$opt_update['name'] = "Test";
-$opt_update['tags'] = null;
-$update = $image->update_image($id_image, $opt_update);
-echo $update->name;
-*/
?> \ No newline at end of file