diff options
| author | EoleDev <EoleDev@outlook.fr> | 2016-02-12 12:11:11 +0100 |
|---|---|---|
| committer | EoleDev <EoleDev@outlook.fr> | 2016-02-12 12:11:11 +0100 |
| commit | af451ad44290f6cf8373b3672da1ada64f91ecfc (patch) | |
| tree | af5e6924ca82bcb676fd4a9342c5e25a59191ffb /server/Test/AppTestClass.php | |
| parent | ad33435ce05302c76618fa77282811ade5a53119 (diff) | |
Add Init and AppClass to do tests, Error Correction in App.php
Diffstat (limited to 'server/Test/AppTestClass.php')
| -rwxr-xr-x | server/Test/AppTestClass.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php new file mode 100755 index 0000000..311b9bf --- /dev/null +++ b/server/Test/AppTestClass.php @@ -0,0 +1,73 @@ +<?php
+include_once("../core/Plugin_Api.php");
+include_once("../core/LibOverride/genTokenOptions.php");
+
+class AppTest{
+
+ protected $openstack;
+ protected $pluginsApi;
+ protected $tokenClass;
+ protected $tokenPost;
+ protected $output;
+
+ public function __construct($args){
+
+ $this->tokenPost = NULL;
+ $this->tokenClass = new genTokenOptions($args);
+ $this->openstack = new OpenStack\OpenStack([]);
+ $this->pluginsApi = plugin_api::getInstance();
+ $this->output = array();
+
+ }
+
+ public function setToken($token){
+
+ $this->tokenPost = $token;
+ $this->tokenClass->loadBackup($his->tokenPost);
+
+ }
+
+ public function getLibClass($service){
+
+ switch($service){
+ case "Identity":
+ if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->identityV3($opt);
+ break;
+ case "Image":
+ if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->imagesV2($opt);
+ break;
+ }
+
+ }
+
+ public function authenticate(){
+
+ try{
+ $this->tokenClass->genIdentityToken();
+ $this->tokenClass->genComputeToken();
+ $this->tokenClass->genImageToken();
+ $this->tokenClass->genNetworkToken();
+
+ $this->setOutput("token", $this->tokenClass->getBackup());
+ }catch(Exception $e){
+ echo $e;
+ exit();
+ }
+
+ }
+
+ public function setOutput($key, $out){
+
+ $this->output[$key] = $out;
+
+ }
+
+ public function show(){
+ echo json_encode($this->output);
+ }
+
+}
\ No newline at end of file |
