A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/aws/aws-sdk-js-v3/commit/35c2bf2805cec575098e75cadc89027ddcac4e62 below:

generate idempotencyTokens in ShapeSerializers… · aws/aws-sdk-js-v3@35c2bf2 · GitHub

1 +

import { CborShapeSerializer } from "@smithy/core/cbor";

2 +

import { sim, struct } from "@smithy/core/schema";

3 +

import { describe, expect, test as it } from "vitest";

4 + 5 +

import { JsonShapeSerializer } from "./json/JsonShapeSerializer";

6 +

import { QueryShapeSerializer } from "./query/QueryShapeSerializer";

7 +

import { XmlShapeSerializer } from "./xml/XmlShapeSerializer";

8 + 9 +

describe("idempotencyToken", () => {

10 +

const structureSchema = struct(

11 +

"ns",

12 +

"StructureWithIdempotencyToken",

13 +

0,

14 +

["idempotencyToken", "plain"],

15 +

[sim("ns", "IdempotencyTokenString", 0, 0b0100), sim("ns", "PlainString", 0, 0b0000)]

16 +

);

17 + 18 +

it("all ShapeSerializer implementations should generate an idempotency token if no input was provided by the caller", () => {

19 +

const serializers = [

20 +

new JsonShapeSerializer({

21 +

timestampFormat: { default: 7, useTrait: true },

22 +

jsonName: true,

23 +

}),

24 +

new QueryShapeSerializer({

25 +

timestampFormat: { default: 7, useTrait: true },

26 +

}),

27 +

new XmlShapeSerializer({

28 +

serviceNamespace: "ServiceNamespace",

29 +

timestampFormat: { default: 7, useTrait: true },

30 +

xmlNamespace: "XmlNamespace",

31 +

}),

32 +

new CborShapeSerializer(),

33 +

];

34 + 35 +

const expectedSerializations = [

36 +

/{"idempotencyToken":"[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}","plain":"potatoes"}/,

37 +

/&idempotencyToken=[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}&plain=potatoes/,

38 +

/<StructureWithIdempotencyToken xmlns="XmlNamespace"><idempotencyToken>([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})<\/idempotencyToken><plain>potatoes<\/plain><\/StructureWithIdempotencyToken>/,

39 +

/pidempotencyTokenx\$([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})eplainhpotatoes/,

40 +

];

41 + 42 +

for (let i = 0; i < expectedSerializations.length; i++) {

43 +

const serializer = serializers[i];

44 +

const expectedSerialization = expectedSerializations[i];

45 + 46 +

// automatic token

47 +

{

48 +

serializer.write(structureSchema, {

49 +

idempotencyToken: undefined,

50 +

plain: "potatoes",

51 +

});

52 +

const data = serializer.flush();

53 +

const serialization = Buffer.from(data).toString("utf8");

54 +

expect(serialization).toMatch(expectedSerialization);

55 +

}

56 + 57 +

// manual token

58 +

{

59 +

serializer.write(structureSchema, {

60 +

idempotencyToken: "00000000-0000-4000-9000-000000000000",

61 +

plain: "potatoes",

62 +

});

63 +

const data = serializer.flush();

64 +

const serialization = Buffer.from(data).toString("utf8");

65 +

expect(serialization).toMatch(expectedSerialization);

66 +

}

67 +

}

68 +

});

69 +

});


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4