Added authentication to tests
diff --git a/.dockerignore b/.dockerignore
index b298e66..849d27a 100755
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,3 +1,4 @@
 views/
 applications/
 containers/
+xos/tests/api/node_modules
\ No newline at end of file
diff --git a/xos/configurations/test-standalone/Makefile b/xos/configurations/test-standalone/Makefile
index c67b495..a7ed841 100644
--- a/xos/configurations/test-standalone/Makefile
+++ b/xos/configurations/test-standalone/Makefile
@@ -7,6 +7,13 @@
 	sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/frontend/sample.yaml
 	sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/fixtures.yaml
 
+restore-initial-db-status:
+	sudo docker exec teststandalone_xos_db_1 psql -U postgres -d xos -c "SELECT truncate_tables('postgres');"
+	sudo docker exec teststandalone_xos_db_1 psql -U postgres -d xos -c "INSERT INTO core_user (id, password, username, email, firstname, lastname, is_admin, last_login, created, updated, is_active, is_staff, is_readonly, is_registering, is_appuser, backend_status) VALUES (1, 'pass', 'padmin@vicci.org', 'padmin@vicci.org', 'xos', 'xos', true, now(), now(), now(), true, true, false, false, false, 'be status');"
+	sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/base.yaml
+	sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/frontend/sample.yaml
+	sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/fixtures.yaml
+
 prepare:
 	# INSTALL DEPS
 	# RUN ONCE BEFORE RUNNING TESTS
diff --git a/xos/tests/api/apiary.apib b/xos/tests/api/apiary.apib
index 154f7d7..43a81c7 100644
--- a/xos/tests/api/apiary.apib
+++ b/xos/tests/api/apiary.apib
@@ -388,7 +388,7 @@
 
 ### Create a vOLT [POST]
 
-+ Request 200 (application/json)
++ Request (application/json)
 
         {
             "s_tag": "222",
@@ -396,7 +396,7 @@
             "subscriber": 1
         }
 
-+ Response 200 (application/json)
++ Response 201 (application/json)
 
         {
                 "humanReadableName": "vOLT-tenant-1",
diff --git a/xos/tests/api/helpers/subscriber.py b/xos/tests/api/helpers/subscriber.py
index 8e6d004..4d702fd 100644
--- a/xos/tests/api/helpers/subscriber.py
+++ b/xos/tests/api/helpers/subscriber.py
@@ -1,15 +1,36 @@
-# NOT used, see https://github.com/apiaryio/dredd-hooks-python/issues/17#issuecomment-206950166
+import dredd_hooks as hooks
+import sys
 
+# HELPERS
+# NOTE move in separated module
 import os
 import sys
 sys.path.append("/opt/xos")
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
 import django
 from core.models import *
-#from hpc.models import *
 from services.cord.models import *
+from services.vtr.models import *
+from django.contrib.auth import authenticate, login
+from django.core.exceptions import PermissionDenied
+from django.contrib.sessions.models import Session
+import urllib2
+import json
 django.setup()
 
+token = ''
+
+
+def doLogin(username, password):
+
+    url = "http://127.0.0.1:8000/xoslib/login?username=%s&password=%s" % (username, password)
+
+    print url
+
+    res = urllib2.urlopen(url).read()
+
+    token = json.loads(res)['xoscsrftoken']
+
 
 def cleanDB():
     # deleting all subscribers
@@ -39,6 +60,8 @@
     for s in NetworkSlice.objects.all():
         s.delete(purge=True)
 
+    print 'DB Cleaned'
+
 
 def createTestSubscriber():
 
@@ -87,7 +110,7 @@
     vcpe_slice.caller = user
     vcpe_slice.save()
 
-    print 'vcpe_slice created'
+    # print 'vcpe_slice created'
 
     # create a lan network
     lan_net = Network()
@@ -96,7 +119,7 @@
     lan_net.template = private_template
     lan_net.save()
 
-    print 'lan_network created'
+    # print 'lan_network created'
 
     # add relation between vcpe slice and lan network
     vcpe_network = NetworkSlice()
@@ -104,7 +127,7 @@
     vcpe_network.slice = vcpe_slice
     vcpe_network.save()
 
-    print 'vcpe network relation added'
+    # print 'vcpe network relation added'
 
     # vbng service
     vbng_service = VBNGService()
@@ -119,6 +142,24 @@
     vt.caller = user
     vt.save()
 
-    print "Subscriber Created"
+    # print "Subscriber Created"
 
-createTestSubscriber()
+
+def deleteTruckrolls():
+    for s in VTRTenant.objects.all():
+        s.delete(purge=True)
+
+
+def setUpTruckroll():
+    service_vtr = VTRService()
+    service_vtr.name = 'service_vtr'
+    service_vtr.save()
+
+
+def createTruckroll():
+    setUpTruckroll()
+    tn = VTRTenant(id=1)
+    tn.save()
+
+
+doLogin('padmin@vicci.org', 'letmein')
diff --git a/xos/tests/api/hooks.py b/xos/tests/api/hooks.py
index 350156f..3c306e1 100644
--- a/xos/tests/api/hooks.py
+++ b/xos/tests/api/hooks.py
@@ -11,9 +11,18 @@
 from core.models import *
 from services.cord.models import *
 from services.vtr.models import *
+import urllib2
+import json
 django.setup()
 
 
+def doLogin(username, password):
+    url = "http://127.0.0.1:8000/xoslib/login?username=%s&password=%s" % (username, password)
+    res = urllib2.urlopen(url).read()
+    parsed = json.loads(res)
+    return {'token': parsed['xoscsrftoken'], 'sessionid': parsed['xossessionid']}
+
+
 def cleanDB():
     # deleting all subscribers
     for s in CordSubscriberRoot.objects.all():
@@ -42,6 +51,8 @@
     for s in NetworkSlice.objects.all():
         s.delete(purge=True)
 
+    # print 'DB Cleaned'
+
 
 def createTestSubscriber():
 
@@ -144,6 +155,9 @@
 
 @hooks.before_each
 def my_before_each_hook(transaction):
+    auth = doLogin('padmin@vicci.org', 'letmein')
+    transaction['request']['headers']['X-CSRFToken'] = auth['token']
+    transaction['request']['headers']['Cookie'] = "xossessionid=%s; xoscsrftoken=%s" % (auth['sessionid'], auth['token'])
     createTestSubscriber()
     sys.stdout.flush()
 
@@ -167,5 +181,5 @@
 
 @hooks.before("vOLT > vOLT Collection > Create a vOLT")
 def test4(transaction):
-    transaction['skip'] = True
-    # VOLTTenant.objects.get(kind='vOLT').delete()
+    # transaction['skip'] = True
+    VOLTTenant.objects.get(kind='vOLT').delete()
diff --git a/xos/tests/api/source/tenant/cord/volt.md b/xos/tests/api/source/tenant/cord/volt.md
index 63c68ad..09140fd 100644
--- a/xos/tests/api/source/tenant/cord/volt.md
+++ b/xos/tests/api/source/tenant/cord/volt.md
@@ -28,7 +28,7 @@
 
 ### Create a vOLT [POST]
 
-+ Request 200 (application/json)
++ Request (application/json)
 
         {
             "s_tag": "222",
@@ -36,7 +36,7 @@
             "subscriber": 1
         }
 
-+ Response 200 (application/json)
++ Response 201 (application/json)
 
         {
                 "humanReadableName": "vOLT-tenant-1",