Reading APIs endpont from swagger definition
diff --git a/xos/core/xoslib/ngXosLib/.bowerrc b/xos/core/xoslib/ngXosLib/.bowerrc
new file mode 100644
index 0000000..637d54e
--- /dev/null
+++ b/xos/core/xoslib/ngXosLib/.bowerrc
@@ -0,0 +1,3 @@
+{
+  "directory": "./bower_components"
+}
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/README.md b/xos/core/xoslib/ngXosLib/README.md
index d1f508b..bbe087f 100644
--- a/xos/core/xoslib/ngXosLib/README.md
+++ b/xos/core/xoslib/ngXosLib/README.md
@@ -10,9 +10,7 @@
 
 Usage: `npm run apigen`
 
-This tool will automatically generate an angular resource file for each endpoint available in Swagger. 
-
-_NOTE: endpoints are listed as an array `apiList` in `xos-resource-generator.js`. If a new endpoint is added, it should be added also to that list._
+This tool will automatically generate an angular resource file for each endpoint available in Swagger.
 
 ### Vendors
 
@@ -89,5 +87,4 @@
 
 - Use Angular $resource instead of $http
 - Use ngDoc instead of jsDoc
-- Define styleguide (both visual and js) and if needed define some UI components
-- Load api endpoints from `http://localhost:9999/docs/api-docs/`
\ No newline at end of file
+- Define styleguide (both visual and js) and if needed define some UI components
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/bower.json b/xos/core/xoslib/ngXosLib/bower.json
index af75f16..c70af72 100644
--- a/xos/core/xoslib/ngXosLib/bower.json
+++ b/xos/core/xoslib/ngXosLib/bower.json
@@ -19,5 +19,8 @@
     "angular-resource": "~1.4.7",
     "ng-lodash": "~0.3.0",
     "angular-cookies": "~1.4.7"
+  },
+  "devDependencies": {
+    "angular-mocks": "~1.4.7"
   }
 }
diff --git a/xos/core/xoslib/ngXosLib/gulpfile.js b/xos/core/xoslib/ngXosLib/gulpfile.js
index 25bf8fa..da08f7e 100644
--- a/xos/core/xoslib/ngXosLib/gulpfile.js
+++ b/xos/core/xoslib/ngXosLib/gulpfile.js
@@ -5,7 +5,7 @@
 
 var options = {
   ngXosVendor: '../static/js/vendor/', //save here the minfied vendor file, this is automatically loaded in the django page
-  xosHelperSource: './xosHelpers/'
+  xosHelperSource: './xosHelpers/src/'
 };
 
 wrench.readdirSyncRecursive('./gulp')
diff --git a/xos/core/xoslib/ngXosLib/karma.conf.js b/xos/core/xoslib/ngXosLib/karma.conf.js
new file mode 100644
index 0000000..06939fb
--- /dev/null
+++ b/xos/core/xoslib/ngXosLib/karma.conf.js
@@ -0,0 +1,84 @@
+// Karma configuration
+// Generated on Tue Oct 06 2015 09:27:10 GMT+0000 (UTC)
+
+/* eslint indent: [2,2], quotes: [2, "single"]*/
+
+/*eslint-disable*/
+var wiredep = require('wiredep');
+var path = require('path');
+
+var bowerComponents = wiredep({devDependencies: true})[ 'js' ].map(function( file ){
+  return path.relative(process.cwd(), file);
+});
+
+module.exports = function(config) {
+/*eslint-enable*/
+  config.set({
+
+    // base path that will be used to resolve all patterns (eg. files, exclude)
+    basePath: '',
+
+
+    // frameworks to use
+    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+    frameworks: ['jasmine'],
+
+
+    // list of files / patterns to load in the browser
+    files: bowerComponents.concat([
+      'xosHelpers/src/*.module.js',
+      'xosHelpers/src/**/*.js',
+      'xosHelpers/spec/**/*.test.js',
+    ]),
+
+
+    // list of files to exclude
+    exclude: [
+    ],
+
+
+    // preprocess matching files before serving them to the browser
+    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+    preprocessors: {
+      '**/*.test.js': ['babel'],
+      'src/**/*.html': ['ng-html2js']
+    },
+
+    ngHtml2JsPreprocessor: {
+      stripPrefix: 'src/', //strip the src path from template url (http://stackoverflow.com/questions/22869668/karma-unexpected-request-when-testing-angular-directive-even-with-ng-html2js)
+      moduleName: 'templates' // define the template module name
+    },
+
+    // test results reporter to use
+    // possible values: 'dots', 'progress'
+    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+    reporters: ['mocha'],
+
+
+    // web server port
+    port: 9876,
+
+
+    // enable / disable colors in the output (reporters and logs)
+    colors: true,
+
+
+    // level of logging
+    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+    logLevel: config.LOG_INFO,
+
+
+    // enable / disable watching file and executing tests whenever any file changes
+    autoWatch: true,
+
+
+    // start these browsers
+    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+    browsers: ['PhantomJS'],
+
+
+    // Continuous Integration mode
+    // if true, Karma captures browsers, runs the tests and exits
+    singleRun: false
+  });
+};
diff --git a/xos/core/xoslib/ngXosLib/package.json b/xos/core/xoslib/ngXosLib/package.json
index f6f1391..8e2fe31 100644
--- a/xos/core/xoslib/ngXosLib/package.json
+++ b/xos/core/xoslib/ngXosLib/package.json
@@ -4,7 +4,7 @@
   "description": "Angular Version of XosLib, containing Helpers and ngResources",
   "main": "index.js",
   "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1",
+    "test": "karma start",
     "apigen": "node xos-resource-generator.js"
   },
   "author": "Matteo Scandolo",
diff --git a/xos/core/xoslib/ngXosLib/xos-resource-generator.js b/xos/core/xoslib/ngXosLib/xos-resource-generator.js
index c28c35c..b24bf9b 100644
--- a/xos/core/xoslib/ngXosLib/xos-resource-generator.js
+++ b/xos/core/xoslib/ngXosLib/xos-resource-generator.js
@@ -44,27 +44,29 @@
 // generator loop //
 ////////////////////
 
-var apiList = ['hpcapi', 'xos', 'xoslib'];
-
 P.coroutine(function*(){
   
   var generatedFiles = [];
 
   console.log(chalk.green('Generating APIs '));
 
+  let mainDef = yield fetchSwagger('http://localhost:9999/docs/api-docs/');
 
-  for(let i = 0; i < apiList.length; i++){
+  for(let i = 0; i < mainDef.apis.length; i++){
     
-    process.stdout.write(chalk.green(`Starting ${apiList[i]} generation `));
+    const path = mainDef.apis[i].path.replace('/', '');
+  
+    process.stdout.write(chalk.green(`Starting ${path} generation `));
     
     let loader = setInterval(function(){
       process.stdout.write(chalk.green('.'));
     }, 500);
 
-    let def = yield fetchSwagger(`http://localhost:9999/docs/api-docs/${apiList[i]}`);
-    yield writeToFile(`api/ng-${apiList[i]}.js`, CodeGen.getAngularCode({ 
-      moduleName: `xos.${apiList[i]}`, 
-      className: `${apiList[i]}`, 
+
+    let def = yield fetchSwagger(`http://localhost:9999/docs/api-docs/${path}`);
+    yield writeToFile(`api/ng-${path}.js`, CodeGen.getAngularCode({ 
+      moduleName: `xos.${path}`, 
+      className: `${path}`, 
       swagger: def,
       lint: false,
       template: {
@@ -74,7 +76,7 @@
     }
     }));
   
-    generatedFiles.push(`api/ng-${apiList[i]}.js`);
+    generatedFiles.push(`api/ng-${path}.js`);
 
     clearInterval(loader);
     process.stdout.write('\n');
diff --git a/xos/core/xoslib/ngXosLib/xosHelpers/spec/csrftoken.test.js b/xos/core/xoslib/ngXosLib/xosHelpers/spec/csrftoken.test.js
new file mode 100644
index 0000000..6a74040
--- /dev/null
+++ b/xos/core/xoslib/ngXosLib/xosHelpers/spec/csrftoken.test.js
@@ -0,0 +1,20 @@
+'use strict';
+
+describe('The xos.helper module', () => {
+  
+  var app, httpProvider;
+
+  beforeEach(module('xos.helpers'));
+  beforeEach(function(){
+    module(function($httpProvider){
+      httpProvider = $httpProvider;
+    });
+  });
+
+
+
+  it('should set SetCSRFToken interceptor', inject(($http) => {
+    expect(httpProvider.interceptors).toContain('SetCSRFToken');
+  }));
+
+});
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/xosHelpers/services/csrfToken.interceptor.js b/xos/core/xoslib/ngXosLib/xosHelpers/src/services/csrfToken.interceptor.js
similarity index 100%
rename from xos/core/xoslib/ngXosLib/xosHelpers/services/csrfToken.interceptor.js
rename to xos/core/xoslib/ngXosLib/xosHelpers/src/services/csrfToken.interceptor.js
diff --git a/xos/core/xoslib/ngXosLib/xosHelpers/services/noHyperlinks.interceptor.js b/xos/core/xoslib/ngXosLib/xosHelpers/src/services/noHyperlinks.interceptor.js
similarity index 100%
rename from xos/core/xoslib/ngXosLib/xosHelpers/services/noHyperlinks.interceptor.js
rename to xos/core/xoslib/ngXosLib/xosHelpers/src/services/noHyperlinks.interceptor.js
diff --git a/xos/core/xoslib/ngXosLib/xosHelpers/xosHelpers.module.js b/xos/core/xoslib/ngXosLib/xosHelpers/src/xosHelpers.module.js
similarity index 100%
rename from xos/core/xoslib/ngXosLib/xosHelpers/xosHelpers.module.js
rename to xos/core/xoslib/ngXosLib/xosHelpers/src/xosHelpers.module.js