javascript: Add endpoint version 6 support to js.

The blessingNamesFromEndpoint method did not support endpoint 6.

Change-Id: Ib0c525a0aff6f32a19a18879c678a436e18b0bd3
diff --git a/src/naming/util.js b/src/naming/util.js
index b885fe9..baeca91 100644
--- a/src/naming/util.js
+++ b/src/naming/util.js
@@ -120,18 +120,19 @@
     }
     return [];
   }
-  if (epversion < 4) {
-    // Versions less than 4 do not support blessing names in the endpoint.
-    return [];
+
+  var blessingNameField = 0;
+  switch(epversion) {
+    case 5:
+      blessingNameField = 5;
+      break;
+    case 6:
+      blessingNameField = 6;
+      break;
+    default:
+      throw new Error('endpoint version ' + epversion + ' not supported');
   }
-  var blessingNameField = 7;
-  if (epversion === 5) {
-    blessingNameField = 5;
-  }
-  if (epversion > 5) {
-    // This code needs to be updated.
-    throw new Error('endpoint version ' + epversion + ' not supported');
-  }
+
   var start = 0;
   // blessing names are the blessingNameField position.
   for (var i = 0; i < blessingNameField; i++) {
diff --git a/test/integration/test-namespace.js b/test/integration/test-namespace.js
index 5712e4e..2da55ca 100644
--- a/test/integration/test-namespace.js
+++ b/test/integration/test-namespace.js
@@ -662,7 +662,7 @@
     var ctx = rt.getContext();
     var ns = rt.namespace();
     var name = 'name/that/will/be/deleted';
-    var ep = '/@5@ws@2.2.2.2:2222@e8972f90fe028674f78a164f001d07c5@s@@';
+    var ep = '/@6@ws@2.2.2.2:2222@@e8972f90fe028674f78a164f001d07c5@s@@';
 
     ns.mount(ctx, name, ep, MINUTE)
       .then(function onMount(err) {
diff --git a/test/unit/test-namespace-util.js b/test/unit/test-namespace-util.js
index 6434423..38b5fbd 100644
--- a/test/unit/test-namespace-util.js
+++ b/test/unit/test-namespace-util.js
@@ -4,7 +4,7 @@
 
 var test = require('prova');
 var names = require('../../src/naming/util');
-var ep = '@4@tcp@127.0.0.1:22@@@@s@dev.v.io/blessing,v.io/blessing/b2@@';
+var ep = '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/blessing,v.io/blessing/b2@@';
 var rootedEp = '/' + ep;
 
 test('names.join(...)', function(assert) {
@@ -141,13 +141,13 @@
     ['/(dev.v.io/services/mounttabled)@host:1234/', '(dev.v.io/services/mounttabled)@host:1234', ''], // jshint ignore:line
     ['/(dev.v.io/services/mounttabled)@host:1234', '(dev.v.io/services/mounttabled)@host:1234', ''], // jshint ignore:line
     // the next two tests have malformed endpoint, doesn't end in a @@
-    ['/@4@tcp@127.0.0.1:22@@@@s@dev.v.io/', '@4@tcp@127.0.0.1:22@@@@s@dev.v.io', ''], // jshint ignore:line
-    ['/@4@tcp@127.0.0.1:22@@@@s@dev.v.io', '@4@tcp@127.0.0.1:22@@@@s@dev.v.io', ''],  // jshint ignore:line
-    ['/@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled@@/foo/bar', '@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled@@', 'foo/bar'],  // jshint ignore:line
-    ['/@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@/foo/bar', '@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@', 'foo/bar'],  // jshint ignore:line
+    ['/@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/', '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io', ''], // jshint ignore:line
+    ['/@6@tcp@127.0.0.1:22@@@@@s@dev.v.io', '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io', ''],  // jshint ignore:line
+    ['/@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled@@/foo/bar', '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled@@', 'foo/bar'],  // jshint ignore:line
+    ['/@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@/foo/bar', '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@', 'foo/bar'],  // jshint ignore:line
     ['/@@@127.0.0.1:22@@@@/foo/bar', '@@@127.0.0.1:22@@@@', 'foo/bar'], // jshint ignore:line
-    ['/@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@', '@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@', ''],  // jshint ignore:line
-    ['/@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled@@/foo/bar', '@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled@@', 'foo/bar'],  // jshint ignore:line
+    ['/@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@', '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled,staging.v.io/services/nsroot@@', ''],  // jshint ignore:line
+    ['/@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled@@/foo/bar', '@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/services/mounttabled@@', 'foo/bar'],  // jshint ignore:line
     [rootedEp, ep, ''],
     [rootedEp + '/b', ep, 'b'],
     [ep, '', ep],
@@ -163,27 +163,19 @@
 
 test('names.blessingNamesFromAddress(addr)', function(assert) {
   var tests = [
-    // Valid v4 endpoints
-    ['@4@tcp@127.0.0.1:22@@@@s@@@', ['']],
-    ['@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled@@',
+    // Valid v6 endpoints
+    ['@6@tcp@127.0.0.1:22@@@s@dev.v.io/services/mounttabled@@',
       ['dev.v.io/services/mounttabled']],
-    ['@5@tcp@127.0.0.1:22@@s@dev.v.io/services/mounttabled@@',
-      ['dev.v.io/services/mounttabled']],
-    ['@4@tcp@127.0.0.1:22@@@@s@dev.v.io/services/mounttabled,foo/bar,batman@dccomics.com/car@@',  // jshint ignore:line
+    ['@6@tcp@127.0.0.1:22@@@s@dev.v.io/services/mounttabled,foo/bar,batman@dccomics.com/car@@',  // jshint ignore:line
       ['dev.v.io/services/mounttabled', 'foo/bar', 'batman@dccomics.com/car']],
-    ['@5@tcp@127.0.0.1:22@@s@dev.v.io/services/mounttabled,foo/bar,batman@dccomics.com/car@@',  // jshint ignore:line
-      ['dev.v.io/services/mounttabled', 'foo/bar', 'batman@dccomics.com/car']],
-    // Well-formed endpoints of old versions.
-    ['@2@tcp@127.0.0.1:21@@@@@', []],
-    ['@3@tcp@127.0.0.1:21@@@@m@@', []],
     // Host:port endpoints
     ['ns.dev.v.io:8101', []],
     ['(dev.v.io/service/mounttabled)@ns.dev.v.io:8101',
       ['dev.v.io/service/mounttabled']],
     // Invalid strings:
     // invalid endpoints since they do not end in @@.
-    ['@4@tcp@127.0.0.1:22@@@@s@dev.v.io/', []],
-    ['@4@tcp@127.0.0.1:22@@@@s@dev.v.io', []],
+    ['@6@tcp@127.0.0.1:22@@@@@s@dev.v.io/', []],
+    ['@6@tcp@127.0.0.1:22@@@@@s@dev.v.io', []],
     // malformed version number
     ['@4c@tcp@127.0.0.1:22@@@@s@foo@@', []],
     ['@-4@tcp@127.0.0.1:22@@@@s@foo@@', []],