Explorar o código

Merged in FD3-241 (pull request #29)

FD3-241
Gabriel Gosparo %!s(int64=7) %!d(string=hai) anos
pai
achega
5bef47688c

+ 8 - 4
.drone.yml

@@ -37,8 +37,10 @@ pipeline:
       - chmod 0777 -R var/logs var/cache var/sessions
       - php bin/console doctrine:schema:update --force -vvv --env=test
       - touch var/logs/test.log
-      - tail -f var/logs/*.log &
-      - vendor/phpunit/phpunit/phpunit --tap -c phpunit.xml.dist
+
+      - tail -f var/logs/*.log & 
+      - bin/console server:run --help --end=prod
+      - vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist
 
  docker:
    repo : docker.infra.flowdat.com/fd3/ftth
@@ -47,8 +49,10 @@ pipeline:
    registry: docker.infra.flowdat.com
    username: drone
    password: 6hd2dLfL
-   tag: latest
+   tag: 
+     - ${DRONE_TAG##v}
+     - latest
    when:
      event: [pull_request, push, tag]
-     branch: master
+     branch: [master, v*]
 

+ 2 - 2
Dockerfile

@@ -41,6 +41,6 @@ CMD eval $(ssh-agent) ; ssh-add /opt/keys/bitbucket.id_rsa ; composer install --
  	cp app/config/hwioauthbundle/parameters.yml.docker app/config/hwioauthbundle/parameters.yml ;\
 	cp app/config/bundles/ik/device-bundle/parameters.yml.docker app/config/bundles/ik/device-bundle/parameters.yml ;\
 	cp app/config/bundles/ik/base-admin-bundle/parameters.yml.dist app/config/bundles/ik/base-admin-bundle/parameters.yml ;\
-    composer run-script post-install-cmd --no-interaction ;\
- 	cat app/config/hwioauthbundle/parameters.yml ;
+	composer run-script post-install-cmd --no-interaction ;\
+ 	cat app/config/hwioauthbundle/parameters.yml ;\
  	bin/console server:run 0.0.0.0 --env=dev

+ 3 - 0
app/AppKernel.php

@@ -50,8 +50,11 @@ class AppKernel extends Kernel
             $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
             $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
             $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
+
         }
 
+	$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
+
         return $bundles;
     }
 

+ 0 - 2
app/config/config.yml

@@ -43,8 +43,6 @@ framework:
     templating:
         engines: ['twig']
     default_locale:  "%locale%"
-    trusted_hosts:   ~
-    trusted_proxies: ~
     session:
         name: ftth_session
         # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id

+ 4 - 0
app/config/config_test.yml

@@ -23,6 +23,10 @@ services:
       class:  Monolog\Formatter\LineFormatter
       calls:
         - [ includeStacktraces ]
+    webservice:
+      class: WebserviceBundle\Services\WebserviceMock
+      arguments: ["@service_container", null, null, null]
+
 # run 181
 # unexpected '1' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /drone/src/bitbucket.org/ikflowdat/ftth/var/cache/test/appTestDebugProjectContainer.php:638
 #      calls: { includeStacktraces: [true] }

+ 3 - 0
app/config/parameters.yml.dist

@@ -34,3 +34,6 @@ parameters:
     db_session_name: fd_session
     db_session_user: root
     db_session_password: null
+
+    # RabbitMQ routing key 
+    env(AMQP_KEY) : ""

+ 43 - 31
composer.json

@@ -17,6 +17,10 @@
         }
     },
     "repositories": [
+        {
+            "type": "composer",
+            "url": "https://satis.infra.flowdat.com/"
+        },
         {
             "type": "vcs",
             "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseAdmin.git",
@@ -101,51 +105,60 @@
             "options": {
                 "local_pk": "./keys/bitbucket.id_rsa"
             }
+        },
+        {
+            "type": "vcs",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/3erPartyFlowdat3/SonataAdminBundle.git",
+            "name": "ik-sonata"
         }
     ],
     "config": {
         "secure-http": false,
-        "optimize-autoloader": true
+        "optimize-autoloader": true,
+	"sort-packages": true
     },
     "require": {
         "php": ">=5.5.9",
-        "symfony/symfony": "3.2.*",
-        "doctrine/orm": "^2.5",
         "doctrine/doctrine-bundle": "^1.6",
         "doctrine/doctrine-cache-bundle": "^1.2",
-        "symfony/swiftmailer-bundle": "^2.3.10",
-        "symfony/monolog-bundle": "^3.0.2",
-        "symfony/polyfill-apcu": "^1.0",
-        "sensio/distribution-bundle": "^5.0",
-        "sensio/framework-extra-bundle": "3.0.23",
-        "incenteev/composer-parameter-handler": "^2.0",
-        "sonata-project/admin-bundle": "^3.12",
-        "sonata-project/doctrine-orm-admin-bundle": "^3.1",
-        "jms/serializer-bundle": "^1.1",
-        "phpunit/phpunit": "5.5.*",
-        "stof/doctrine-extensions-bundle": "^1.2",
-        "voryx/restgeneratorbundle": "dev-master",
+        "doctrine/doctrine-migrations-bundle": "^1.2",
+        "doctrine/instantiator": "^1.0.5",
+        "doctrine/orm": "^2.5",
+        "ik/audit-bundle": "dev-master",
+        "ik/auth-bundle": "dev-master",
         "ik/base-admin-bundle": "dev-master",
-        "ik/oauthclient-bundle": "dev-master",
-        "ik/webservice-bundle": "dev-master",
-        "hwi/oauth-bundle": "^0.5.3",
-        "ik/workflow-bundle": "dev-master",
-        "php-amqplib/rabbitmq-bundle": "^1.12",
-        "ik/template-bundle": "dev-master",
-        "ik/extra-data-bundle": "dev-master",
         "ik/device-bundle": "dev-master",
-        "ik/owner-voter-bundle": "dev-master",
-        "doctrine/doctrine-migrations-bundle": "^1.2",
-        "ik/migrations-bundle": "dev-master",
-        "samsonasik/package-versions": "1.1.0",
+        "ik/extra-data-bundle": "dev-master",
         "ik/leaflet-bundle": "dev-master",
         "ik/map-bundle": "dev-master",
-        "ik/auth-bundle": "dev-master",
-        "ik/audit-bundle": "dev-master"
+        "ik/migrations-bundle": "dev-master",
+        "ik/oauthclient-bundle": "dev-master",
+        "ik/owner-voter-bundle": "dev-master",
+        "ik/template-bundle": "dev-master",
+        "ik/webservice-bundle": "dev-workflow_update",
+        "ik/workflow-bundle": "dev-workflow_update",
+        "incenteev/composer-parameter-handler": "^2.0",
+        "jms/serializer": "^1.9.0",
+        "jms/serializer-bundle": "^1.5.0",
+        "php-amqplib/rabbitmq-bundle": "^1.12",
+        "sensio/distribution-bundle": "^5.0.21",
+        "sensio/framework-extra-bundle": "^3.0.2",
+        "sonata-project/admin-bundle": "dev-bf4681",
+        "sonata-project/doctrine-orm-admin-bundle": "^3.1",
+        "stof/doctrine-extensions-bundle": "^1.2",
+        "symfony/monolog-bundle": "^3.1.0",
+        "symfony/polyfill-apcu": "^1.0",
+        "symfony/swiftmailer-bundle": "^2.3.10",
+        "symfony/symfony": "3.3.*",
+        "symfony/web-server-bundle": "^3.3",
+        "twig/extensions": "^1.5",
+        "twig/twig": "^2.0",
+        "voryx/restgeneratorbundle": "dev-master"
     },
     "require-dev": {
+        "phpunit/phpunit": "^6.4",
         "sensio/generator-bundle": "^3.0",
-        "symfony/phpunit-bridge": "^3.0"
+        "symfony/phpunit-bridge": "^3.3"
     },
     "scripts": {
         "workflows-commands": [
@@ -210,7 +223,6 @@
             {
                 "file": "app/config/bundles/ik/base-admin-bundle/parameters.yml"
             }
-        ],
-        "branch-alias": null
+        ]
     }
 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2228 - 1766
composer.lock


+ 0 - 1
src/FTTHBundle/Controller/ONURESTController.php

@@ -103,7 +103,6 @@ class ONURESTController extends RESTController
 		    $errorsString = (string) $errors;
 		    return FOSView::create($errorsString, Codes::HTTP_INTERNAL_SERVER_ERROR);
 	    }else{
-		    $entity->setAdministrativeState("suspend");
 		    $em->persist($entity);
 		    $em->flush($entity);
 

+ 25 - 28
src/FTTHBundle/tests/ONURESTControllerTest.php

@@ -41,10 +41,10 @@ class ONURESTControllerTest extends WebTestCaseBase
             json_encode(array(array("name" => "Stock", "id" => 1)));
         $datos['api/devices/check'] =
             json_encode(array(array('result' => true, 'errors' => null)));
-	$datos['api/devices'] =
+        $datos['api/devices'] =
             json_encode(array('id' => 1));
 
-	$datos["client"] = array(array("id"=> 1));
+        $datos["client"] = array(array("id" => 1));
 
 
         return $datos;
@@ -65,8 +65,7 @@ class ONURESTControllerTest extends WebTestCaseBase
         $datos['profileId'] = '1';
         $datos['mac'] = '00:11:22:33';
         $datos['ponSerialNumber'] = 'pon';
-        $datos['clientId'] = array('name' => 'Stock GZ [pruebass]');
-        //$datos['transitionState'] = 'ts';
+        $datos['clientId'] = 1;
         $datos['tenancyId'] = 1;
         $datos['deviceId'] = 1;
 
@@ -105,6 +104,20 @@ class ONURESTControllerTest extends WebTestCaseBase
         return $this->getClient()->getResponse();
     }
 
+    /**
+     * Sobreescribe el device.device_listener
+     */
+    private function setListener()
+    {
+        $webservicemock = $this->getContainerObject('webservice');
+        $listener = $this->getContainerObject('device.device_listener');
+        $listener->setWebservice($webservicemock);
+        //$this->setContainerObject('device.device_listener', $listener);
+        $validator = $this->getContainerObject('device.device_validator');
+        $validator->setWebservice($webservicemock);
+        //$this->setContainerObject('device.device_validator', $validator);
+    }
+
     /**
      * Realiza el alta.
      * post_onu -> /api/onus.{_format}
@@ -121,8 +134,6 @@ class ONURESTControllerTest extends WebTestCaseBase
         $this->getClient()->request('POST', $this->getUri(), $this->obtainData());
         // obtengo la respuesta
         $response = $this->getClient()->getResponse();
-
-        var_dump($response->getContent());
         $this->assertEquals(201, $response->getStatusCode(), "Error en la respuesta http.");
     }
 
@@ -196,25 +207,25 @@ class ONURESTControllerTest extends WebTestCaseBase
         $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
         $this->assertJson($json = $response->getContent(), "No se obtuvo un objeto json.");
 
-	$json = json_decode($json, true);
-	$json = $json[0];
+        $json = json_decode($json, true);
+        $json = $json[0];
 
-	$this->assertEquals("active", $json["administrativeState"]);
+        $this->assertEquals("active", $json["administrativeState"]);
 
         $this->initDefault($this->obtainDataWebService());
 
         $original = $this->getClient()->getContainer()->get('device.device_listener');
-	$fakeWebService = $this->getClient()->getContainer()->get('webservice');
-	$original->setWebservice($fakeWebService);
+        $fakeWebService = $this->getClient()->getContainer()->get('webservice');
+        $original->setWebservice($fakeWebService);
 
 	$this->getClient()->request('PATCH',
 		$this->getUriPutDelete().  $json["id"] . "/apply/administrative_state/active_to_suspend.json" , array());
         $response = $this->getClient()->getResponse();
 
-	$json = json_decode($response->getContent(), true);
+        $json = json_decode($response->getContent(), true);
 
         $this->assertEquals(201, $response->getStatusCode(), "Error en la respuesta http.");
-	$this->assertEquals("suspend", $json["administrativeState"]);
+        $this->assertEquals("suspend", $json["administrativeState"]);
 
         $response = $this->getClient()->getResponse();
     }
@@ -254,21 +265,7 @@ class ONURESTControllerTest extends WebTestCaseBase
         $this->assertJson($response->getContent(), "No se obtuvo un objeto json.");
     }
 
-    /**
-     * Sobreescribe el device.device_listener
-     */
-    private function setListener()
-    {
-        $webservicemock = $this->getContainerObject('webService');
-        $listener = $this->getContainerObject('device.device_listener');
-        $listener->setWebservice($webservicemock);
-        $this->setContainerObject('device.device_listener', $listener);
-        $validator = $this->getContainerObject('device.device_validator');
-        $validator->setWebservice($webservicemock);
-        $this->setContainerObject('device.device_validator', $validator);
-    }
-
-
+    
     /**
      * Realiza el alta.
      * post_onu -> /api/onus.{_format}