Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 2 docs/ChaosHandlerSamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ client
// OverRiding to Random mode, providing the chaos percentage as 60(percentage times the error would be generated from handler)
client
.api("/me")
.middlewareOptions([new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.RANDOM, undefined, "I generated the error", 60)])
.middlewareOptions([new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.RANDOM, "I generated the error", undefined, 60)])
.get()
.then((res) => {
console.log(res);
Expand Down
2 changes: 1 addition & 1 deletion 2 spec/development/workload/PageIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("PageIterator", function() {
return true;
};

const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, 200, "middleware options for pageIterator", 0, responseBody)];
const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, "middleware options for pageIterator", 200, 0, responseBody)];
const requestOptions = { middlewareOptions };

const client = Client.initWithMiddleware(clientOptions);
Expand Down
12 changes: 6 additions & 6 deletions 12 spec/middleware/ChaosHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("ChaosHandler.ts", () => {
};

it("Should return a valid response object for MANUAL case", () => {
chaosHandler["createResponse"](new ChaosHandlerOptions(ChaosStrategy.MANUAL, 404), cxt);
chaosHandler["createResponse"](new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Manual response", 404), cxt);
assert.isDefined(cxt.response);
});

Expand Down Expand Up @@ -90,7 +90,7 @@ describe("ChaosHandler.ts", () => {
});

it("Should send the request to the graph", async () => {
handler["sendRequest"](new ChaosHandlerOptions(ChaosStrategy.RANDOM, undefined, "I generated the error", 100), cxt);
handler["sendRequest"](new ChaosHandlerOptions(ChaosStrategy.RANDOM, "I generated the error", undefined, 100), cxt);
assert.isDefined(cxt.response);
});
});
Expand Down Expand Up @@ -143,13 +143,13 @@ describe("ChaosHandler.ts", () => {
const tempChaosHandlerManualRegex = new ChaosHandler(tempManualOptionsRegex, manualMap);

it("Should set a statusCode for MANUAL mode", () => {
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.MANUAL, 404);
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Set status code", 404);
chaosHandler["setStatusCode"](tempOptions, "https://graph.microsoft.com/v1.0/me", RequestMethod.GET);
assert.isDefined(tempOptions.statusCode);
});

it("Should set a statusCode for RANDOM mode", () => {
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.RANDOM, undefined, "I generated the error", 100);
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.RANDOM, "I generated the error", undefined, 100);
chaosHandler["setStatusCode"](tempOptions, "https://graph.microsoft.com/v1.0/me", RequestMethod.POST);
assert.isDefined(tempOptions.statusCode);
});
Expand All @@ -167,7 +167,7 @@ describe("ChaosHandler.ts", () => {

describe("getOptions", () => {
it("Should return the options in the context object", () => {
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, 405);
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Get options", 405);
const cxt: Context = {
request: "url",
middlewareControl: new MiddlewareControl([options]),
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("ChaosHandler.ts", () => {
});

it("Should return response for Manual Request Level case", async () => {
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, 200);
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Manual Request level case", 200);
const cxt: Context = {
request: "https://graph.microsoft.com/v1.0/me",
options: {
Expand Down
4 changes: 2 additions & 2 deletions 4 src/middleware/options/ChaosHandlerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export class ChaosHandlerOptions implements MiddlewareOptions {
* @constructor
* To create an instance of Testing Handler Options
* @param {ChaosStrategy} ChaosStrategy - Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL
* @param {number?} statusCode - The statusCode to be returned in the response
* @param {string} statusMessage - The Message to be returned in the response
* @param {number?} statusCode - The statusCode to be returned in the response
* @param {number?} chaosPercentage - The percentage of randomness/chaos in the handler
* @param {any?} responseBody - The response body to be returned in the response
* @returns An instance of ChaosHandlerOptions
*/
public constructor(chaosStrategy: ChaosStrategy = ChaosStrategy.RANDOM, statusCode?: number, statusMessage: string = "Some error Happened", chaosPercentage?: number, responseBody?: any) {
public constructor(chaosStrategy: ChaosStrategy = ChaosStrategy.RANDOM, statusMessage: string = "Some error Happened", statusCode?: number, chaosPercentage?: number, responseBody?: any) {
this.chaosStrategy = chaosStrategy;
this.statusCode = statusCode;
this.statusMessage = statusMessage;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.