Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/raft-tools/auth/node-js/msal/msal_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function get_token(client_id, tenant_id, secret, scopes, authority_uri, callback
msalInstance.acquireTokenByClientCredential(accessTokenRequest).then(function(accessTokenResponse) {
callback(null, accessTokenResponse.tokenType + ' ' + accessTokenResponse.accessToken);
}).catch(function (error) {
log.error(error);
console.error(error);
callback(error);
})
}
Expand Down
48 changes: 43 additions & 5 deletions cli/raft-tools/tools/Dredd/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { config } = require('../../libs/node-js/raft');

const toolDirectory = process.env.RAFT_TOOL_RUN_DIRECTORY;
console.log(toolDirectory + "/../../libs/node-js/raft.js");

Expand All @@ -26,15 +28,14 @@ raft.installCertificates((error, result) => {
raftUtils.flush();
});
} else {
var Dredd = require('dredd');
const EventEmitter = require('events');
let eventEmitter = new EventEmitter();

let headers = [];
if (result) {
headers = ["Authorization: " + result];
}
var Dredd = require('dredd');
const EventEmitter = require('events');
let eventEmitter = new EventEmitter();
console.log(raftUtils.config);

let configuration = {
init: false,
Expand All @@ -53,8 +54,45 @@ raft.installCertificates((error, result) => {
require: null, // String, When using nodejs hooks, require the given module before executing hooks
color: true,
emitter: eventEmitter, // listen to test progress, your own instance of EventEmitter
path: raft.config.targetConfiguration.apiSpecifications
path: raft.config.targetConfiguration.apiSpecifications,
sorted : false
}

if (raft.config.toolConfiguration) {
const toolConfig = raft.config.toolConfiguration;
if (toolConfig.header) {
console.log("Adding extra headers to configuration");
configuration.header = configuration.header.concat(toolConfig.header);
}

if (toolConfig["dry-run"]) {
console.log("Dry-run is set");
configuration['dry-run'] = toolConfig["dry-run"];
}

if (toolConfig.only) {
console.log("Setting 'only' transaction names");
configuration.only = toolConfig.only;
}

if (toolConfig.hookfiles) {
console.log("Setting hook files");
configuration.hookfiles = toolConfig.hookfiles;
}

if (toolConfig.require) {
console.log("Setting node-js hooks require");
configuration.require = toolConfig.require;
}

if (toolConfig.sorted) {
console.log("Setting sorted configuration");
configuration.sorted = toolConfig.sorted;
}
}

console.log(raft.config);

var dredd = new Dredd(configuration);

//This is very ugly hack to address:
Expand Down
54 changes: 54 additions & 0 deletions cli/raft-tools/tools/Dredd/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

{
"openapi": "3.0.1",
"info": {
"title": "Dredd",
"version": "v2"
},
"paths": {},
"components": {
"schemas": {
"Dredd" : {
"type" : "object",
"properties" : {
"sorted" : {
"type" : "boolean",
"description" : "Sorts requests in a sensible way so that objects are not modified before they are created. Order: CONNECT, OPTIONS, POST, GET, HEAD, PUT, PATCH, LINK, UNLINK, DELETE, TRACE."
},
"dry-run" : {
"type" : "boolean",
"description": "Boolean, do not run any real HTTP transaction"
},
"only" : {
"type": "array",
"items": {
"type": "string"
},
"description" : "Array of Strings, run only transaction that match these names"
},
"header" : {
"type": "array",
"items": {
"type": "string"
},
"description" : "Array of Strings, these strings are then added as headers (key:value) to every transaction"
},
"hookfiles" : {
"type": "array",
"items": {
"type": "string"
},
"description" : "Array of Strings, filepaths to files containing hooks (can use glob wildcards)"
},
"require" : {
"type": "array",
"items": {
"type": "string"
},
"description" : "String, When using nodejs hooks, require the given module before executing hooks"
}
}
}
}
}
}
9 changes: 6 additions & 3 deletions cli/raft.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def validate(defaults):
skip_sp_deployment = args.get('skip_sp_deployment')
service_cli.deploy(
args['sku'], skip_sp_deployment and skip_sp_deployment is True)
elif service_action == 'upload-tools':
elif service_action == 'upload-tools' or service_action == 'update':
utils_file_share = f'{uuid.uuid4()}'
service_cli.upload_utils(
utils_file_share, args.get('custom_tools_path'))
Expand Down Expand Up @@ -313,7 +313,7 @@ def main():
formatter_class=argparse.RawTextHelpFormatter)
service_parser.add_argument(
'service-action',
choices=['deploy', 'restart', 'info', 'upload-tools'],
choices=['deploy', 'restart', 'info', 'upload-tools', 'update'],
help=textwrap.dedent('''\
deploy - Deploys the service

Expand All @@ -322,7 +322,10 @@ def main():

info - Show the version of the service and the last time it was started

upload-tools - Uploads the tool definitions to the service
upload-tools - Uploads the tools definitions to the service

update - Uploads the tools definitions to the service and
restarts service to get latest service components
'''))

allowed_skus = [
Expand Down
9 changes: 8 additions & 1 deletion cli/samples/dredd/petstore/dredd.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
"tasks": [
{
"toolName" : "Dredd",
"outputFolder" : "dredd"
"outputFolder" : "dredd",
"toolConfiguration" : {
"dry-run" : true,
"only" : [],
"header" : [],
"hookfiles" : [],
"require" : null
}
}
]
}
Expand Down