-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathtest-large-objects.js
93 lines (91 loc) · 3.31 KB
/
test-large-objects.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {
runTests,
MakeRequest,
HasStatus,
HasHeaders,
HasCommonResponseHeaders,
DoesNotHaveHeaders,
HasNoBody,
CorsBlocked,
Skip
} from './harness.js'
import { GetClusterInfo } from './test-info.js'
function MakeSloRequest () {
return GetClusterInfo.then((clusterInfo) => {
if (!('slo' in clusterInfo)) {
throw new Skip('SLO is not enabled')
}
return MakeRequest(...arguments)
})
}
runTests('large object', [
['GET DLO',
() => MakeRequest('GET', 'public-with-cors/dlo')
.then(HasStatus(200, 'OK'))
.then(HasCommonResponseHeaders)
.then(HasHeaders({
'Content-Type': 'application/octet-stream',
ETag: '"8d431e7531abb83a6cf67e56d91c6f74"'
}))
.then(DoesNotHaveHeaders(['X-Object-Manifest'])) // TODO: should maybe be exposed
.then((resp) => {
if (resp.responseText.length !== 10485760) {
throw new Error('Expected body to have length 10485760, got ' + resp.responseText.length)
}
})],
['GET DLO with unlistable segments',
() => MakeRequest('GET', 'public-with-cors/dlo-with-unlistable-segments')
.then(CorsBlocked)], // TODO: should probably be Unauthorized
['GET SLO',
() => MakeSloRequest('GET', 'public-with-cors/slo')
.then(HasStatus(200, 'OK'))
.then(HasCommonResponseHeaders)
.then(HasHeaders({
'Content-Type': 'application/octet-stream',
ETag: '"8d431e7531abb83a6cf67e56d91c6f74"'
}))
.then(DoesNotHaveHeaders(['X-Static-Large-Object'])) // TODO: should maybe be exposed
.then((resp) => {
if (resp.responseText.length !== 10485760) {
throw new Error('Expected body to have length 10485760, got ' + resp.responseText.length)
}
})],
['HEAD SLO',
() => MakeSloRequest('HEAD', 'public-with-cors/slo')
.then(HasStatus(200, 'OK'))
.then(HasCommonResponseHeaders)
.then(HasHeaders({
'Content-Type': 'application/octet-stream',
ETag: '"8d431e7531abb83a6cf67e56d91c6f74"'
}))
.then(DoesNotHaveHeaders(['X-Static-Large-Object'])) // TODO: should maybe be exposed
.then(HasNoBody)],
['GET SLO Range',
() => MakeSloRequest('GET', 'public-with-cors/slo', { Range: 'bytes=100-199' })
.then(HasStatus(206, 'Partial Content'))
.then(HasCommonResponseHeaders)
.then(HasHeaders({
'Content-Type': 'application/octet-stream',
ETag: '"8d431e7531abb83a6cf67e56d91c6f74"'
}))
.then(DoesNotHaveHeaders(['X-Static-Large-Object'])) // TODO: should maybe be exposed
.then((resp) => {
if (resp.responseText.length !== 100) {
throw new Error('Expected body to have length 100, got ' + resp.responseText.length)
}
})],
['GET SLO Suffix Range',
() => MakeSloRequest('GET', 'public-with-cors/slo', { Range: 'bytes=-100' })
.then(HasStatus(206, 'Partial Content'))
.then(HasCommonResponseHeaders)
.then(HasHeaders({
'Content-Type': 'application/octet-stream',
ETag: '"8d431e7531abb83a6cf67e56d91c6f74"'
}))
.then(DoesNotHaveHeaders(['X-Static-Large-Object'])) // TODO: should maybe be exposed
.then((resp) => {
if (resp.responseText.length !== 100) {
throw new Error('Expected body to have length 100, got ' + resp.responseText.length)
}
})]
])