Skip to content

Commit a2ab148

Browse files
authored
relax http exchange attachment type (via #3340)
1 parent 93e6fee commit a2ab148

9 files changed

Lines changed: 69 additions & 7 deletions

File tree

allure-generator/src/main/java/io/qameta/allure/detect/WellKnownFileExtensionsUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,7 @@ public final class WellKnownFileExtensionsUtils {
13561356
for (Map.Entry<String, String> stringStringEntry : EXT_TO_MIME_TYPE.entrySet()) {
13571357
extToMimeType.putIfAbsent(stringStringEntry.getValue(), stringStringEntry.getKey());
13581358
}
1359+
extToMimeType.put("application/vnd.allure.http", "httpexchange");
13591360
MIME_TYPE_TO_EXT = Collections.unmodifiableMap(extToMimeType);
13601361
}
13611362

allure-generator/src/main/javascript/features/attachments/index.mts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HTTP_EXCHANGE_ATTACHMENT_MIME } from "./model/httpAttachment.mts";
1+
import { HTTP_EXCHANGE_ATTACHMENT_MIME_TYPES } from "./model/httpAttachment.mts";
22
import { HttpAttachmentView } from "./views/HttpAttachmentView.mts";
33
import { ScreenDiffAttachmentView, ScreenDiffTestResultView } from "./views/ScreenDiffView.mts";
44

@@ -7,10 +7,15 @@ type TestResultBlockFactory = import("../../core/registry/types.mts").TestResult
77
type TestResultBlocks = import("../../core/registry/types.mts").TestResultBlocks;
88

99
export const attachmentViewers: AttachmentViewers = {
10-
[HTTP_EXCHANGE_ATTACHMENT_MIME]: {
11-
create: HttpAttachmentView,
12-
icon: "lineDevDataflow3",
13-
},
10+
...Object.fromEntries(
11+
HTTP_EXCHANGE_ATTACHMENT_MIME_TYPES.map((type) => [
12+
type,
13+
{
14+
create: HttpAttachmentView,
15+
icon: "lineDevDataflow3",
16+
},
17+
]),
18+
),
1419
"application/vnd.allure.image.diff": {
1520
create: ScreenDiffAttachmentView,
1621
icon: "lineLayoutsColumns2",

allure-generator/src/main/javascript/features/attachments/model/httpAttachment.mts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export const HTTP_EXCHANGE_ATTACHMENT_MIME = "application/vnd.allure.http+json";
1+
const HTTP_EXCHANGE_ATTACHMENT_MIME = "application/vnd.allure.http+json";
2+
const HTTP_EXCHANGE_ATTACHMENT_MIME_ALIAS = "application/vnd.allure.http";
3+
export const HTTP_EXCHANGE_ATTACHMENT_MIME_TYPES = [
4+
HTTP_EXCHANGE_ATTACHMENT_MIME,
5+
HTTP_EXCHANGE_ATTACHMENT_MIME_ALIAS,
6+
];
27
export const HTTP_EXCHANGE_REDACTED_VALUE = "__ALLURE_REDACTED__";
38

49
export type HttpExchangeSchemaVersion = 1;

allure-generator/src/test/java/io/qameta/allure/detect/WellKnownFileExtensionsUtilsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static Stream<Arguments> expectedExtensions() {
7474
Arguments.of("application/gzip", "tgz"),
7575
Arguments.of("application/vnd.allure.image.diff", "imagediff"),
7676
Arguments.of("application/vnd.allure.http+json", "httpexchange"),
77+
Arguments.of("application/vnd.allure.http", "httpexchange"),
7778
Arguments.of("text/plain", "txt"),
7879
Arguments.of("application/octet-stream", ""),
7980
Arguments.of("", ""),

allure-generator/tests/e2e/attachments.spec.mts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,21 @@ test.describe("Generic Attachments", () => {
227227
.toBe(false);
228228
await expect(preview.getByRole("button", { name: "Copy as curl" })).toHaveCount(0);
229229
await expect(preview.locator("[data-body-mode]")).toHaveCount(0);
230+
231+
const httpAliasRow = attachmentRow(page, attachmentsFixture.attachments.httpAlias);
232+
await expect(httpAliasRow).toBeVisible();
233+
await expect(httpAliasRow).toHaveAttribute("data-type", "application/vnd.allure.http");
234+
await httpAliasRow.click();
235+
236+
const aliasPreview = previewContainerFor(httpAliasRow);
237+
await expect(aliasPreview.locator(".http-attachment__summary")).toBeVisible();
238+
await expect(aliasPreview.locator(".http-attachment__method")).toHaveText("GET");
239+
await expect(aliasPreview.locator(".http-attachment__url")).toHaveText(
240+
"https://api.example.com/v1/mime-alias",
241+
);
242+
await expect(aliasPreview.locator(".http-attachment__status")).toHaveText(
243+
"204 No Content",
244+
);
230245
});
231246

232247
test(`renders rich HTTP Exchange response bodies with attachment viewers (${mode})`, async ({

allure-generator/tests/e2e/support/fixtures.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const fixtures = {
7171
css: "text/css",
7272
imageDiff: "application/vnd.allure.image.diff",
7373
http: "HTTP Exchange",
74+
httpAlias: "HTTP Exchange MIME alias",
7475
httpBinary: "HTTP Exchange binary",
7576
httpForm: "HTTP Exchange form",
7677
httpImage: "HTTP Exchange image",
@@ -94,6 +95,7 @@ export const fixtures = {
9495
css: "text/css",
9596
imageDiff: "application/vnd.allure.image.diff",
9697
http: "HTTP Exchange",
98+
httpAlias: "HTTP Exchange MIME alias",
9799
httpBinary: "HTTP Exchange binary",
98100
httpForm: "HTTP Exchange form",
99101
httpImage: "HTTP Exchange image",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"schemaVersion": 1,
3+
"start": 1710000186680,
4+
"stop": 1710000186700,
5+
"request": {
6+
"method": "GET",
7+
"url": "https://api.example.com/v1/mime-alias",
8+
"httpVersion": "HTTP/1.1",
9+
"headers": [
10+
{
11+
"name": "accept",
12+
"value": "application/json"
13+
}
14+
]
15+
},
16+
"response": {
17+
"status": 204,
18+
"statusText": "No Content",
19+
"httpVersion": "HTTP/1.1"
20+
}
21+
}

allure-generator/tests/fixtures/raw/attachments/attachments-01-result.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@
156156
}
157157
]
158158
},
159+
{
160+
"status": "passed",
161+
"name": "HTTP Exchange MIME alias",
162+
"start": 1710000186680,
163+
"stop": 1710000186700,
164+
"attachments": [
165+
{
166+
"name": "HTTP Exchange MIME alias",
167+
"type": "application/vnd.allure.http",
168+
"source": "attachment-http-alias.httpexchange"
169+
}
170+
]
171+
},
159172
{
160173
"status": "passed",
161174
"name": "HTTP Exchange image",

allurerc.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const { ALLURE_SERVICE_TOKEN } = process.env;
33
const allureService = ALLURE_SERVICE_TOKEN
44
? {
55
accessToken: ALLURE_SERVICE_TOKEN,
6-
legacy: true,
76
}
87
: undefined;
98

0 commit comments

Comments
 (0)