diff options
Diffstat (limited to 'catalog-fe/src/test/testScripts')
-rw-r--r-- | catalog-fe/src/test/testScripts/filesContents.js | 207 | ||||
-rw-r--r-- | catalog-fe/src/test/testScripts/jasmine-fixture.js | 453 |
2 files changed, 660 insertions, 0 deletions
diff --git a/catalog-fe/src/test/testScripts/filesContents.js b/catalog-fe/src/test/testScripts/filesContents.js new file mode 100644 index 0000000000..b2e7aa2c65 --- /dev/null +++ b/catalog-fe/src/test/testScripts/filesContents.js @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +var normativeTypesRootYml = "tosca_definitions_version: tosca_simple_yaml_1_0_0_wd03"+ + +"template_name: tosca-normative-types-root"+ +"template_author: TOSCA TC"+ +"template_version: 1.0.0.wd03-SNAPSHOT"+ +"description: Contains the normative types definition."+ +"node_types:"+ +" tosca.nodes.Root:"+ +" abstract: true"+ +" description: >"+ +" This is the default (root) TOSCA Node Type that all other TOSCA nodes should extends."+ +" This allows all TOSCA nodes to have a consistent set of features for modeling and management"+ +" (e.g, consistent definitions for requirements, capabilities, and lifecycle interfaces)."+ +" tags:"+ +" icon: /images/root.png"+ +" attributes:"+ +" tosca_id:"+ +" type: string"+ +" tosca_name:"+ +" type: string"+ +" requirements:"+ +" dependency:"+ +" type: tosca.capabilities.Root"+ +" lower_bound: 0"+ +" upper_bound: unbounded"+ +" capabilities:"+ +" root:"+ +" type: tosca.capabilities.Root"+ +" interfaces:"+ +" tosca.interfaces.node.lifecycle.Standard:"+ +" description: >"+ +" This lifecycle interface defines the essential, normative operations that TOSCA nodes may support."+ +" create:"+ +" description: Standard lifecycle create operation."+ +" configure:"+ +" description: Standard lifecycle configure operation (pre-start)."+ +" start:"+ +" description: Standard lifecycle start operation."+ +" post_start:"+ +" description: Standard lifecycle post-configure operation (post-start)"+ +" stop:"+ +" description: Standard lifecycle stop operation."+ +" delete:"+ +" description: Standard lifecycle delete operation."+ +"capability_types:"+ +" tosca.capabilities.Root:"+ +" description: This is the default (root) TOSCA Capability Type definition that all other TOSCA Capability Types derive from."+ +"relationship_types:"+ +" tosca.relationships.Root:"+ +" abstract: true"+ +" description: This is the default (root) TOSCA Relationship Type definition that all other TOSCA Relationship Types derive from."+ +" valid_targets: [ tosca.capabilities.Root ]"+ +" attributes:"+ +" tosca_id:"+ +" type: string"+ +" tosca_name:"+ +" type: string"+ +" interfaces:"+ +" tosca.interfaces.relationship.Configure:"+ +" description: >"+ +" The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support."+ +" pre_configure_source:"+ +" description: Operation to pre-configure the source endpoint."+ +" pre_configure_target:"+ +" description: Operation to pre-configure the target endpoint."+ +" post_configure_source:"+ +" description: Operation to post-configure the source endpoint."+ +" post_configure_target:"+ +" description: Operation to post-configure the target endpoint."+ +" add_target:"+ +" description: Operation to notify the source node of a target node being added via a relationship."+ +" add_source:"+ +" description: Operation to notify the target node of a source node which is now available via a relationship."+ +" remove_target:"+ +" description: Operation to notify the source node of a target node being removed from a relationship."+ +" remove_source:"+ +" description: Operation to notify the target node of a source node being removed from a relationship."+ +" target_changed:"+ +" description: Operation to notify source some property or attribute of the target."+ +" source_changed:"+ +" description: Operation to notify target some property or attribute of the source."+ +"artifact_types:"+ +" tosca.artifacts.Root:"+ +" description: The TOSCA Artifact Type all other TOSCA Artifact Types derive from."; + + +var mysqlTypeYml = +"tosca_definitions_version: tosca_simple_yaml_1_0_0_wd03"+ +"description: MySQL RDBMS installation on a specific mounted volume path."+ +"template_name: mysql-type"+ +"template_version: 2.0.0-SNAPSHOT"+ +"template_author: FastConnect"+ + +"imports:"+ +' - "tosca-normative-types:1.0.0.wd03-SNAPSHOT"'+ + +"node_types:"+ +" alien.nodes.Mysql:"+ +" derived_from: tosca.nodes.Database"+ +" description: >"+ +" A node to install MySQL v5.5 database with data"+ +" on a specific attached volume."+ +" capabilities:"+ +" host:"+ +" type: alien.capabilities.MysqlDatabase"+ +" properties:"+ +" valid_node_types: [ tosca.nodes.WebApplication ]"+ +" requirements:"+ +" - host: tosca.nodes.Compute"+ +" type: tosca.relationships.HostedOn"+ +" tags:"+ +" icon: /images/mysql.png"+ +" properties:"+ +" db_port:"+ +" type: integer"+ +" default: 3306"+ +" description: The port on which the underlying database service will listen to data."+ +" db_name:"+ +" type: string"+ +" required: true"+ +" default: wordpress"+ +" description: The logical name of the database."+ +" db_user:"+ +" type: string"+ +" default: pass"+ +" description: The special user account used for database administration."+ +" db_password:"+ +" type: string"+ +" default: pass"+ +" description: The password associated with the user account provided in the ‘db_user’ property."+ +" bind_address:"+ +" type: boolean"+ +" default: true"+ +" required: false"+ +" description: If true,the server accepts TCP/IP connections on all server host IPv4 interfaces."+ +" storage_path:"+ +" type: string"+ +" default: /mountedStorage"+ +" constraints:"+ +' - valid_values: [ "/mountedStorage", "/var/mysql" ]'+ +" interfaces:"+ +" Standard:"+ +" create: scripts/install_mysql.sh"+ +" start:"+ +" inputs:"+ +" VOLUME_HOME: { get_property: [SELF, storage_path] }"+ +" PORT: { get_property: [SELF, db_port] }"+ +" DB_NAME: { get_property: [SELF, db_name] }"+ +" DB_USER: { get_property: [SELF, db_user] }"+ +" DB_PASSWORD: { get_property: [SELF, db_password] }"+ +" BIND_ADRESS: { get_property: [SELF, bind_address] }"+ +" implementation: scripts/start_mysql.sh"+ +" "+ +"capability_types:"+ +" alien.capabilities.MysqlDatabase:"+ +" derived_from: tosca.capabilities.Container"; + + +var installMySqlSH = +'#!/bin/bash'+ + +'echo "Debian based MYSQL install 5..."'+ +'LOCK="/tmp/lockaptget"'+ + +'while true; do'+ +' if mkdir "${LOCK}" &>/dev/null; then'+ +' echo "MySQL take the lock"'+ +' break;'+ +' fi'+ +' echo "Waiting the end of one of our recipes..."'+ +' sleep 0.5'+ +'done'+ + +'while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do'+ +' echo "Waiting for other software managers to finish..."'+ +' sleep 0.5'+ +'done'+ +'sudo rm -f /var/lib/dpkg/lock'+ + +'sudo apt-get update || (sleep 15; sudo apt-get update || exit ${1})'+ +'sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server-5.5 pwgen || exit ${1}'+ +'rm -rf "${LOCK}"'+ + +'sudo /etc/init.d/mysql stop'+ +'sudo rm -rf /var/lib/apt/lists/*'+ +'sudo rm -rf /var/lib/mysql/*'+ +'echo "MySQL Installation complete."'; diff --git a/catalog-fe/src/test/testScripts/jasmine-fixture.js b/catalog-fe/src/test/testScripts/jasmine-fixture.js new file mode 100644 index 0000000000..18ff8c6418 --- /dev/null +++ b/catalog-fe/src/test/testScripts/jasmine-fixture.js @@ -0,0 +1,453 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/* jasmine-fixture - 1.2.2 + * Makes injecting HTML snippets into the DOM easy & clean! + * https://github.com/searls/jasmine-fixture + */ +(function() { + var createHTMLBlock, + __slice = [].slice; + + (function($) { + var ewwSideEffects, jasmineFixture, originalAffix, originalJasmineDotFixture, originalJasmineFixture, root, _, _ref; + root = this; + originalJasmineFixture = root.jasmineFixture; + originalJasmineDotFixture = (_ref = root.jasmine) != null ? _ref.fixture : void 0; + originalAffix = root.affix; + _ = function(list) { + return { + inject: function(iterator, memo) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = list.length; _i < _len; _i++) { + item = list[_i]; + _results.push(memo = iterator(memo, item)); + } + return _results; + } + }; + }; + root.jasmineFixture = function($) { + var $whatsTheRootOf, affix, create, jasmineFixture, noConflict; + affix = function(selectorOptions) { + return create.call(this, selectorOptions, true); + }; + create = function(selectorOptions, attach) { + var $top; + $top = null; + _(selectorOptions.split(/[ ](?=[^\]]*?(?:\[|$))/)).inject(function($parent, elementSelector) { + var $el; + if (elementSelector === ">") { + return $parent; + } + $el = createHTMLBlock($, elementSelector); + if (attach || $top) { + $el.appendTo($parent); + } + $top || ($top = $el); + return $el; + }, $whatsTheRootOf(this)); + return $top; + }; + noConflict = function() { + var currentJasmineFixture, _ref1; + currentJasmineFixture = jasmine.fixture; + root.jasmineFixture = originalJasmineFixture; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = originalJasmineDotFixture; + } + root.affix = originalAffix; + return currentJasmineFixture; + }; + $whatsTheRootOf = function(that) { + if (that.jquery != null) { + return that; + } else if ($('#jasmine_content').length > 0) { + return $('#jasmine_content'); + } else { + return $('<div id="jasmine_content"></div>').appendTo('body'); + } + }; + jasmineFixture = { + affix: affix, + create: create, + noConflict: noConflict + }; + ewwSideEffects(jasmineFixture); + return jasmineFixture; + }; + ewwSideEffects = function(jasmineFixture) { + var _ref1; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = jasmineFixture; + } + $.fn.affix = root.affix = jasmineFixture.affix; + return afterEach(function() { + return $('#jasmine_content').remove(); + }); + }; + if ($) { + return jasmineFixture = root.jasmineFixture($); + } else { + return root.affix = function() { + var nowJQueryExists; + nowJQueryExists = window.jQuery || window.$; + if (nowJQueryExists != null) { + jasmineFixture = root.jasmineFixture(nowJQueryExists); + return affix.call.apply(affix, [this].concat(__slice.call(arguments))); + } else { + throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$"); + } + }; + } + })(window.jQuery || window.$); + + createHTMLBlock = (function() { + var bindData, bindEvents, parseAttributes, parseClasses, parseContents, parseEnclosure, parseReferences, parseVariableScope, regAttr, regAttrDfn, regAttrs, regCBrace, regClass, regClasses, regData, regDatas, regEvent, regEvents, regExclamation, regId, regReference, regTag, regTagNotContent, regZenTagDfn; + createHTMLBlock = function($, ZenObject, data, functions, indexes) { + var ZenCode, arr, block, blockAttrs, blockClasses, blockHTML, blockId, blockTag, blocks, el, el2, els, forScope, indexName, inner, len, obj, origZenCode, paren, result, ret, zc, zo; + if ($.isPlainObject(ZenObject)) { + ZenCode = ZenObject.main; + } else { + ZenCode = ZenObject; + ZenObject = { + main: ZenCode + }; + } + origZenCode = ZenCode; + if (indexes === undefined) { + indexes = {}; + } + if (ZenCode.charAt(0) === "!" || $.isArray(data)) { + if ($.isArray(data)) { + forScope = ZenCode; + } else { + obj = parseEnclosure(ZenCode, "!"); + obj = obj.substring(obj.indexOf(":") + 1, obj.length - 1); + forScope = parseVariableScope(ZenCode); + } + while (forScope.charAt(0) === "@") { + forScope = parseVariableScope("!for:!" + parseReferences(forScope, ZenObject)); + } + zo = ZenObject; + zo.main = forScope; + el = $(); + if (ZenCode.substring(0, 5) === "!for:" || $.isArray(data)) { + if (!$.isArray(data) && obj.indexOf(":") > 0) { + indexName = obj.substring(0, obj.indexOf(":")); + obj = obj.substr(obj.indexOf(":") + 1); + } + arr = ($.isArray(data) ? data : data[obj]); + zc = zo.main; + if ($.isArray(arr) || $.isPlainObject(arr)) { + $.map(arr, function(value, index) { + var next; + zo.main = zc; + if (indexName !== undefined) { + indexes[indexName] = index; + } + if (!$.isPlainObject(value)) { + value = { + value: value + }; + } + next = createHTMLBlock($, zo, value, functions, indexes); + if (el.length !== 0) { + return $.each(next, function(index, value) { + return el.push(value); + }); + } + }); + } + if (!$.isArray(data)) { + ZenCode = ZenCode.substr(obj.length + 6 + forScope.length); + } else { + ZenCode = ""; + } + } else if (ZenCode.substring(0, 4) === "!if:") { + result = parseContents("!" + obj + "!", data, indexes); + if (result !== "undefined" || result !== "false" || result !== "") { + el = createHTMLBlock($, zo, data, functions, indexes); + } + ZenCode = ZenCode.substr(obj.length + 5 + forScope.length); + } + ZenObject.main = ZenCode; + } else if (ZenCode.charAt(0) === "(") { + paren = parseEnclosure(ZenCode, "(", ")"); + inner = paren.substring(1, paren.length - 1); + ZenCode = ZenCode.substr(paren.length); + zo = ZenObject; + zo.main = inner; + el = createHTMLBlock($, zo, data, functions, indexes); + } else { + blocks = ZenCode.match(regZenTagDfn); + block = blocks[0]; + if (block.length === 0) { + return ""; + } + if (block.indexOf("@") >= 0) { + ZenCode = parseReferences(ZenCode, ZenObject); + zo = ZenObject; + zo.main = ZenCode; + return createHTMLBlock($, zo, data, functions, indexes); + } + block = parseContents(block, data, indexes); + blockClasses = parseClasses($, block); + if (regId.test(block)) { + blockId = regId.exec(block)[1]; + } + blockAttrs = parseAttributes(block, data); + blockTag = (block.charAt(0) === "{" ? "span" : "div"); + if (ZenCode.charAt(0) !== "#" && ZenCode.charAt(0) !== "." && ZenCode.charAt(0) !== "{") { + blockTag = regTag.exec(block)[1]; + } + if (block.search(regCBrace) !== -1) { + blockHTML = block.match(regCBrace)[1]; + } + blockAttrs = $.extend(blockAttrs, { + id: blockId, + "class": blockClasses, + html: blockHTML + }); + el = $("<" + blockTag + ">", blockAttrs); + el.attr(blockAttrs); + el = bindEvents(block, el, functions); + el = bindData(block, el, data); + ZenCode = ZenCode.substr(blocks[0].length); + ZenObject.main = ZenCode; + } + if (ZenCode.length > 0) { + if (ZenCode.charAt(0) === ">") { + if (ZenCode.charAt(1) === "(") { + zc = parseEnclosure(ZenCode.substr(1), "(", ")"); + ZenCode = ZenCode.substr(zc.length + 1); + } else if (ZenCode.charAt(1) === "!") { + obj = parseEnclosure(ZenCode.substr(1), "!"); + forScope = parseVariableScope(ZenCode.substr(1)); + zc = obj + forScope; + ZenCode = ZenCode.substr(zc.length + 1); + } else { + len = Math.max(ZenCode.indexOf("+"), ZenCode.length); + zc = ZenCode.substring(1, len); + ZenCode = ZenCode.substr(len); + } + zo = ZenObject; + zo.main = zc; + els = $(createHTMLBlock($, zo, data, functions, indexes)); + els.appendTo(el); + } + if (ZenCode.charAt(0) === "+") { + zo = ZenObject; + zo.main = ZenCode.substr(1); + el2 = createHTMLBlock($, zo, data, functions, indexes); + $.each(el2, function(index, value) { + return el.push(value); + }); + } + } + ret = el; + return ret; + }; + bindData = function(ZenCode, el, data) { + var datas, i, split; + if (ZenCode.search(regDatas) === 0) { + return el; + } + datas = ZenCode.match(regDatas); + if (datas === null) { + return el; + } + i = 0; + while (i < datas.length) { + split = regData.exec(datas[i]); + if (split[3] === undefined) { + $(el).data(split[1], data[split[1]]); + } else { + $(el).data(split[1], data[split[3]]); + } + i++; + } + return el; + }; + bindEvents = function(ZenCode, el, functions) { + var bindings, fn, i, split; + if (ZenCode.search(regEvents) === 0) { + return el; + } + bindings = ZenCode.match(regEvents); + if (bindings === null) { + return el; + } + i = 0; + while (i < bindings.length) { + split = regEvent.exec(bindings[i]); + if (split[2] === undefined) { + fn = functions[split[1]]; + } else { + fn = functions[split[2]]; + } + $(el).bind(split[1], fn); + i++; + } + return el; + }; + parseAttributes = function(ZenBlock, data) { + var attrStrs, attrs, i, parts; + if (ZenBlock.search(regAttrDfn) === -1) { + return undefined; + } + attrStrs = ZenBlock.match(regAttrDfn); + attrs = {}; + i = 0; + while (i < attrStrs.length) { + parts = regAttr.exec(attrStrs[i]); + attrs[parts[1]] = ""; + if (parts[3] !== undefined) { + attrs[parts[1]] = parseContents(parts[3], data); + } + i++; + } + return attrs; + }; + parseClasses = function($, ZenBlock) { + var classes, clsString, i; + ZenBlock = ZenBlock.match(regTagNotContent)[0]; + if (ZenBlock.search(regClasses) === -1) { + return undefined; + } + classes = ZenBlock.match(regClasses); + clsString = ""; + i = 0; + while (i < classes.length) { + clsString += " " + regClass.exec(classes[i])[1]; + i++; + } + return $.trim(clsString); + }; + parseContents = function(ZenBlock, data, indexes) { + var html; + if (indexes === undefined) { + indexes = {}; + } + html = ZenBlock; + if (data === undefined) { + return html; + } + while (regExclamation.test(html)) { + html = html.replace(regExclamation, function(str, str2) { + var begChar, fn, val; + begChar = ""; + if (str.indexOf("!for:") > 0 || str.indexOf("!if:") > 0) { + return str; + } + if (str.charAt(0) !== "!") { + begChar = str.charAt(0); + str = str.substring(2, str.length - 1); + } + fn = new Function("data", "indexes", "var r=undefined;" + "with(data){try{r=" + str + ";}catch(e){}}" + "with(indexes){try{if(r===undefined)r=" + str + ";}catch(e){}}" + "return r;"); + val = unescape(fn(data, indexes)); + return begChar + val; + }); + } + html = html.replace(/\\./g, function(str) { + return str.charAt(1); + }); + return unescape(html); + }; + parseEnclosure = function(ZenCode, open, close, count) { + var index, ret; + if (close === undefined) { + close = open; + } + index = 1; + if (count === undefined) { + count = (ZenCode.charAt(0) === open ? 1 : 0); + } + if (count === 0) { + return; + } + while (count > 0 && index < ZenCode.length) { + if (ZenCode.charAt(index) === close && ZenCode.charAt(index - 1) !== "\\") { + count--; + } else { + if (ZenCode.charAt(index) === open && ZenCode.charAt(index - 1) !== "\\") { + count++; + } + } + index++; + } + ret = ZenCode.substring(0, index); + return ret; + }; + parseReferences = function(ZenCode, ZenObject) { + ZenCode = ZenCode.replace(regReference, function(str) { + var fn; + str = str.substr(1); + fn = new Function("objs", "var r=\"\";" + "with(objs){try{" + "r=" + str + ";" + "}catch(e){}}" + "return r;"); + return fn(ZenObject, parseReferences); + }); + return ZenCode; + }; + parseVariableScope = function(ZenCode) { + var forCode, rest, tag; + if (ZenCode.substring(0, 5) !== "!for:" && ZenCode.substring(0, 4) !== "!if:") { + return undefined; + } + forCode = parseEnclosure(ZenCode, "!"); + ZenCode = ZenCode.substr(forCode.length); + if (ZenCode.charAt(0) === "(") { + return parseEnclosure(ZenCode, "(", ")"); + } + tag = ZenCode.match(regZenTagDfn)[0]; + ZenCode = ZenCode.substr(tag.length); + if (ZenCode.length === 0 || ZenCode.charAt(0) === "+") { + return tag; + } else if (ZenCode.charAt(0) === ">") { + rest = ""; + rest = parseEnclosure(ZenCode.substr(1), "(", ")", 1); + return tag + ">" + rest; + } + return undefined; + }; + regZenTagDfn = /([#\.\@]?[\w-]+|\[([\w-!?=:"']+(="([^"]|\\")+")? {0,})+\]|\~[\w$]+=[\w$]+|&[\w$]+(=[\w$]+)?|[#\.\@]?!([^!]|\\!)+!){0,}(\{([^\}]|\\\})+\})?/i; + regTag = /(\w+)/i; + regId = /(?:^|\b)#([\w-!]+)/i; + regTagNotContent = /((([#\.]?[\w-]+)?(\[([\w!]+(="([^"]|\\")+")? {0,})+\])?)+)/i; + /* + See lookahead syntax (?!) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp + */ + + regClasses = /(\.[\w-]+)(?!["\w])/g; + regClass = /\.([\w-]+)/i; + regReference = /(@[\w$_][\w$_\d]+)/i; + regAttrDfn = /(\[([\w-!]+(="?([^"]|\\")+"?)? {0,})+\])/ig; + regAttrs = /([\w-!]+(="([^"]|\\")+")?)/g; + regAttr = /([\w-!]+)(="?((([\w]+(\[.*?\])+)|[^"\]]|\\")+)"?)?/i; + regCBrace = /\{(([^\}]|\\\})+)\}/i; + regExclamation = /(?:([^\\]|^))!([^!]|\\!)+!/g; + regEvents = /\~[\w$]+(=[\w$]+)?/g; + regEvent = /\~([\w$]+)=([\w$]+)/i; + regDatas = /&[\w$]+(=[\w$]+)?/g; + regData = /&([\w$]+)(=([\w$]+))?/i; + return createHTMLBlock; + })(); + +}).call(this); |