index.test.ts
This file
Path
runtime-tests/lambda-edge/index.test.ts
1,134 lines 路 31.5 KiB 路 TypeScript
Last changed by
chore: bump linter and formatter (#4568)ryubefore adoptionb6f4bcd
History of this fileTake it
1import type {2 Callback,3 CloudFrontConfig,4 CloudFrontRequest,5 CloudFrontResponse,6} from '../../src/adapter/lambda-edge/handler'7import { handle } from '../../src/adapter/lambda-edge/handler'8import { Hono } from '../../src/hono'9import { basicAuth } from '../../src/middleware/basic-auth'1011type Bindings = {12 callback: Callback13 config: CloudFrontConfig14 request: CloudFrontRequest15 response: CloudFrontResponse16}1718describe('Lambda@Edge Adapter for Hono', () => {19 const app = new Hono<{ Bindings: Bindings }>()2021 app.get('/', (c) => {22 return c.text('Hello Lambda!')23 })2425 app.get('/binary', (c) => {26 return c.body('Fake Image', 200, {27 'Content-Type': 'image/png',28 })29 })3031 app.post('/post', async (c) => {32 const body = (await c.req.parseBody()) as { message: string }33 return c.text(body.message)34 })3536 app.get('/callback/request', async (c, next) => {37 await next()38 c.env.callback(null, c.env.request)39 })4041 app.get('/config/eventCheck', async (c, next) => {42 await next()43 if (c.env.config.eventType in ['viewer-request', 'origin-request']) {44 c.env.callback(null, c.env.request)45 } else {46 c.env.callback(null, c.env.response)47 }48 })4950 app.get('/callback/response', async (c, next) => {51 await next()52 c.env.callback(null, c.env.response)53 })5455 app.post('/post/binary', async (c) => {56 const body = await c.req.blob()57 return c.text(`${body.size} bytes`)58 })5960 const username = 'hono-user-a'61 const password = 'hono-password-a'62 app.use('/auth/*', basicAuth({ username, password }))63 app.get('/auth/abc', (c) => c.text('Good Night Lambda!'))6465 app.get('/header/add', async (c, next) => {66 c.env.response.headers['Strict-Transport-Security'.toLowerCase()] = [67 {68 key: 'Strict-Transport-Security',69 value: 'max-age=63072000; includeSubdomains; preload',70 },71 ]72 c.env.response.headers['X-Custom'.toLowerCase()] = [73 {74 key: 'X-Custom',75 value: 'Foo',76 },77 ]78 await next()79 c.env.callback(null, c.env.response)80 })8182 const handler = handle(app)8384 it('Should handle a GET request and return a 200 response (Lambda@Edge viewer request)', async () => {85 const event = {86 Records: [87 {88 cf: {89 config: {90 distributionDomainName: 'd111111abcdef8.cloudfront.net',91 distributionId: 'EDFDVBD6EXAMPLE',92 eventType: 'viewer-request',93 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',94 },95 request: {96 clientIp: '203.0.113.178',97 headers: {98 host: [99 {100 key: 'Host',101 value: 'd111111abcdef8.cloudfront.net',102 },103 ],104 'user-agent': [105 {106 key: 'User-Agent',107 value: 'curl/7.66.0',108 },109 ],110 accept: [111 {112 key: 'accept',113 value: '*/*',114 },115 ],116 },117 method: 'GET',118 querystring: '',119 uri: '/',120 },121 },122 },123 ],124 }125 const response = await handler(event)126 expect(response.status).toBe('200')127 expect(response.body).toBe('Hello Lambda!')128 if (response.headers && response.headers['content-type']) {129 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)130 } else {131 throw new Error("'content-type' header is missing in the response")132 }133 })134135 it('Should handle a GET request and return a 200 response (Lambda@Edge origin request)', async () => {136 const event = {137 Records: [138 {139 cf: {140 config: {141 distributionDomainName: 'd111111abcdef8.cloudfront.net',142 distributionId: 'EDFDVBD6EXAMPLE',143 eventType: 'origin-request',144 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',145 },146 request: {147 clientIp: '203.0.113.178',148 headers: {149 'x-forwarded-for': [150 {151 key: 'X-Forwarded-For',152 value: '203.0.113.178',153 },154 ],155 'user-agent': [156 {157 key: 'User-Agent',158 value: 'Amazon CloudFront',159 },160 ],161 via: [162 {163 key: 'Via',164 value: '2.0 2afae0d44e2540f472c0635ab62c232b.cloudfront.net (CloudFront)',165 },166 ],167 host: [168 {169 key: 'Host',170 value: 'example.org',171 },172 ],173 'cache-control': [174 {175 key: 'Cache-Control',176 value: 'no-cache',177 },178 ],179 },180 method: 'GET',181 origin: {182 custom: {183 customHeaders: {},184 domainName: 'example.org',185 keepaliveTimeout: 5,186 path: '',187 port: 443,188 protocol: 'https',189 readTimeout: 30,190 sslProtocols: ['TLSv1', 'TLSv1.1', 'TLSv1.2'],191 },192 },193 querystring: '',194 uri: '/',195 },196 },197 },198 ],199 }200 const response = await handler(event)201 expect(response.status).toBe('200')202 expect(response.body).toBe('Hello Lambda!')203 if (response.headers && response.headers['content-type']) {204 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)205 } else {206 throw new Error("'content-type' header is missing in the response")207 }208 })209210 it('Should handle a GET request and return a 200 response (Lambda@Edge viewer response)', async () => {211 const event = {212 Records: [213 {214 cf: {215 config: {216 distributionDomainName: 'd111111abcdef8.cloudfront.net',217 distributionId: 'EDFDVBD6EXAMPLE',218 eventType: 'viewer-response',219 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',220 },221 request: {222 clientIp: '203.0.113.178',223 headers: {224 host: [225 {226 key: 'Host',227 value: 'd111111abcdef8.cloudfront.net',228 },229 ],230 'user-agent': [231 {232 key: 'User-Agent',233 value: 'curl/7.66.0',234 },235 ],236 accept: [237 {238 key: 'accept',239 value: '*/*',240 },241 ],242 },243 method: 'GET',244 querystring: '',245 uri: '/',246 },247 response: {248 headers: {249 'access-control-allow-credentials': [250 {251 key: 'Access-Control-Allow-Credentials',252 value: 'true',253 },254 ],255 'access-control-allow-origin': [256 {257 key: 'Access-Control-Allow-Origin',258 value: '*',259 },260 ],261 date: [262 {263 key: 'Date',264 value: 'Mon, 13 Jan 2020 20:14:56 GMT',265 },266 ],267 'referrer-policy': [268 {269 key: 'Referrer-Policy',270 value: 'no-referrer-when-downgrade',271 },272 ],273 server: [274 {275 key: 'Server',276 value: 'ExampleCustomOriginServer',277 },278 ],279 'x-content-type-options': [280 {281 key: 'X-Content-Type-Options',282 value: 'nosniff',283 },284 ],285 'x-frame-options': [286 {287 key: 'X-Frame-Options',288 value: 'DENY',289 },290 ],291 'x-xss-protection': [292 {293 key: 'X-XSS-Protection',294 value: '1; mode=block',295 },296 ],297 age: [298 {299 key: 'Age',300 value: '2402',301 },302 ],303 'content-type': [304 {305 key: 'Content-Type',306 value: 'text/html; charset=utf-8',307 },308 ],309 'content-length': [310 {311 key: 'Content-Length',312 value: '9593',313 },314 ],315 },316 status: '200',317 statusDescription: 'OK',318 },319 },320 },321 ],322 }323 const response = await handler(event)324 expect(response.status).toBe('200')325 expect(response.body).toBe('Hello Lambda!')326 if (response.headers && response.headers['content-type']) {327 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)328 } else {329 throw new Error("'content-type' header is missing in the response")330 }331 })332333 it('Should handle a GET request and return a 200 response (Lambda@Edge origin response)', async () => {334 const event = {335 Records: [336 {337 cf: {338 config: {339 distributionDomainName: 'd111111abcdef8.cloudfront.net',340 distributionId: 'EDFDVBD6EXAMPLE',341 eventType: 'origin-response',342 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',343 },344 request: {345 clientIp: '203.0.113.178',346 headers: {347 'x-forwarded-for': [348 {349 key: 'X-Forwarded-For',350 value: '203.0.113.178',351 },352 ],353 'user-agent': [354 {355 key: 'User-Agent',356 value: 'Amazon CloudFront',357 },358 ],359 via: [360 {361 key: 'Via',362 value: '2.0 8f22423015641505b8c857a37450d6c0.cloudfront.net (CloudFront)',363 },364 ],365 host: [366 {367 key: 'Host',368 value: 'example.org',369 },370 ],371 'cache-control': [372 {373 key: 'Cache-Control',374 value: 'no-cache',375 },376 ],377 },378 method: 'GET',379 origin: {380 custom: {381 customHeaders: {},382 domainName: 'example.org',383 keepaliveTimeout: 5,384 path: '',385 port: 443,386 protocol: 'https',387 readTimeout: 30,388 sslProtocols: ['TLSv1', 'TLSv1.1', 'TLSv1.2'],389 },390 },391 querystring: '',392 uri: '/',393 },394 response: {395 headers: {396 'access-control-allow-credentials': [397 {398 key: 'Access-Control-Allow-Credentials',399 value: 'true',400 },401 ],402 'access-control-allow-origin': [403 {404 key: 'Access-Control-Allow-Origin',405 value: '*',406 },407 ],408 date: [409 {410 key: 'Date',411 value: 'Mon, 13 Jan 2020 20:12:38 GMT',412 },413 ],414 'referrer-policy': [415 {416 key: 'Referrer-Policy',417 value: 'no-referrer-when-downgrade',418 },419 ],420 server: [421 {422 key: 'Server',423 value: 'ExampleCustomOriginServer',424 },425 ],426 'x-content-type-options': [427 {428 key: 'X-Content-Type-Options',429 value: 'nosniff',430 },431 ],432 'x-frame-options': [433 {434 key: 'X-Frame-Options',435 value: 'DENY',436 },437 ],438 'x-xss-protection': [439 {440 key: 'X-XSS-Protection',441 value: '1; mode=block',442 },443 ],444 'content-type': [445 {446 key: 'Content-Type',447 value: 'text/html; charset=utf-8',448 },449 ],450 'content-length': [451 {452 key: 'Content-Length',453 value: '9593',454 },455 ],456 },457 status: '200',458 statusDescription: 'OK',459 },460 },461 },462 ],463 }464 const response = await handler(event)465 expect(response.status).toBe('200')466 expect(response.body).toBe('Hello Lambda!')467 if (response.headers && response.headers['content-type']) {468 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)469 } else {470 throw new Error("'content-type' header is missing in the response")471 }472 })473474 it('Should handle a GET request and return a 200 response with binary', async () => {475 const event = {476 Records: [477 {478 cf: {479 config: {480 distributionDomainName: 'example.com',481 distributionId: 'EXAMPLE123',482 eventType: 'viewer-request',483 requestId: 'exampleRequestId',484 },485 request: {486 clientIp: '123.123.123.123',487 headers: {488 host: [489 {490 key: 'Host',491 value: 'example.com',492 },493 ],494 },495 method: 'GET',496 querystring: '',497 uri: '/binary',498 },499 },500 },501 ],502 }503504 const response = await handler(event)505506 expect(response.status).toBe('200')507 expect(response.body).toBe('RmFrZSBJbWFnZQ==') // base64 encoded fake image508 if (response.headers && response.headers['content-type']) {509 expect(response.headers['content-type'][0].value).toMatch(/^image\/png/)510 } else {511 throw new Error("'content-type' header is missing in the response")512 }513 })514515 it('Should handle a GET request and return a 404 response', async () => {516 const event = {517 Records: [518 {519 cf: {520 config: {521 distributionDomainName: 'example.com',522 distributionId: 'EXAMPLE123',523 eventType: 'viewer-request',524 requestId: 'exampleRequestId',525 },526 request: {527 clientIp: '123.123.123.123',528 headers: {529 host: [530 {531 key: 'Host',532 value: 'example.com',533 },534 ],535 },536 method: 'GET',537 querystring: '',538 uri: '/nothing',539 },540 },541 },542 ],543 }544545 const response = await handler(event)546547 expect(response.status).toBe('404')548 })549550 it('Should handle a POST request and return a 200 response', async () => {551 const searchParam = new URLSearchParams()552 searchParam.append('message', 'Good Morning Lambda!')553554 const event = {555 Records: [556 {557 cf: {558 config: {559 distributionDomainName: 'example.com',560 distributionId: 'EXAMPLE123',561 eventType: 'viewer-request',562 requestId: 'exampleRequestId',563 },564 request: {565 clientIp: '123.123.123.123',566 headers: {567 host: [568 {569 key: 'Host',570 value: 'example.com',571 },572 ],573 'content-type': [574 {575 key: 'Content-Type',576 value: 'application/x-www-form-urlencoded',577 },578 ],579 },580 method: 'POST',581 querystring: '',582 uri: '/post',583 body: {584 inputTruncated: false,585 action: 'read-only',586 encoding: 'base64',587 data: Buffer.from(searchParam.toString()).toString('base64'),588 },589 },590 },591 },592 ],593 }594595 const response = await handler(event)596597 expect(response.status).toBe('200')598 expect(response.body).toBe('Good Morning Lambda!')599 })600601 it('Should handle a POST request with binary and return a 200 response', async () => {602 const array = new Uint8Array([0xc0, 0xff, 0xee])603 const buffer = Buffer.from(array)604 const event = {605 Records: [606 {607 cf: {608 config: {609 distributionDomainName: 'example.com',610 distributionId: 'EXAMPLE123',611 eventType: 'viewer-request',612 requestId: 'exampleRequestId',613 },614 request: {615 clientIp: '123.123.123.123',616 headers: {617 host: [618 {619 key: 'Host',620 value: 'example.com',621 },622 ],623 'content-type': [624 {625 key: 'Content-Type',626 value: 'application/x-www-form-urlencoded',627 },628 ],629 },630 method: 'POST',631 querystring: '',632 uri: '/post/binary',633 body: {634 inputTruncated: false,635 action: 'read-only',636 encoding: 'base64',637 data: buffer.toString('base64'),638 },639 },640 },641 },642 ],643 }644645 const response = await handler(event)646 expect(response.status).toBe('200')647 expect(response.body).toBe('3 bytes')648 })649650 it('Should handle a request and return a 401 response with Basic auth', async () => {651 const event = {652 Records: [653 {654 cf: {655 config: {656 distributionDomainName: 'example.com',657 distributionId: 'EXAMPLE123',658 eventType: 'viewer-request',659 requestId: 'exampleRequestId',660 },661 request: {662 clientIp: '123.123.123.123',663 headers: {664 host: [665 {666 key: 'Host',667 value: 'example.com',668 },669 ],670 'content-type': [671 {672 key: 'Content-Type',673 value: 'plain/text',674 },675 ],676 },677 method: 'GET',678 querystring: '',679 uri: '/auth/abc',680 },681 },682 },683 ],684 }685686 const response = await handler(event)687688 expect(response.status).toBe('401')689 })690691 it('Should handle a request and return a 401 response with Basic auth', async () => {692 const event = {693 Records: [694 {695 cf: {696 config: {697 distributionDomainName: 'example.com',698 distributionId: 'EXAMPLE123',699 eventType: 'viewer-request',700 requestId: 'exampleRequestId',701 },702 request: {703 clientIp: '123.123.123.123',704 headers: {705 host: [706 {707 key: 'Host',708 value: 'example.com',709 },710 ],711 'content-type': [712 {713 key: 'Content-Type',714 value: 'plain/text',715 },716 ],717 },718 method: 'GET',719 querystring: '',720 uri: '/auth/abc',721 },722 },723 },724 ],725 }726727 const response = await handler(event)728729 expect(response.status).toBe('401')730 })731732 it('Should call a callback to continue processing the request', async () => {733 const event = {734 Records: [735 {736 cf: {737 config: {738 distributionDomainName: 'example.com',739 distributionId: 'EXAMPLE123',740 eventType: 'viewer-request',741 requestId: 'exampleRequestId',742 },743 request: {744 clientIp: '123.123.123.123',745 headers: {},746 method: 'GET',747 querystring: '',748 uri: '/callback/request',749 },750 },751 },752 ],753 }754755 let called = false756 let requestClientIp = ''757758 await handler(event, {}, (_err, result) => {759 if (result && 'clientIp' in result) {760 requestClientIp = result.clientIp761 }762 called = true763 })764765 expect(called).toBe(true)766 expect(requestClientIp).toBe('123.123.123.123')767 })768769 it('Should call a callback to continue processing the response', async () => {770 const event = {771 Records: [772 {773 cf: {774 config: {775 distributionDomainName: 'example.com',776 distributionId: 'EDFDVBD6EXAMPLE',777 eventType: 'viewer-response',778 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',779 },780 request: {781 clientIp: '203.0.113.178',782 headers: {783 host: [784 {785 key: 'Host',786 value: 'example.com',787 },788 ],789 'user-agent': [790 {791 key: 'User-Agent',792 value: 'curl/7.66.0',793 },794 ],795 accept: [796 {797 key: 'accept',798 value: '*/*',799 },800 ],801 },802 method: 'GET',803 querystring: '',804 uri: '/callback/response',805 },806 response: {807 headers: {808 'access-control-allow-credentials': [809 {810 key: 'Access-Control-Allow-Credentials',811 value: 'true',812 },813 ],814 'access-control-allow-origin': [815 {816 key: 'Access-Control-Allow-Origin',817 value: '*',818 },819 ],820 date: [821 {822 key: 'Date',823 value: 'Mon, 13 Jan 2020 20:14:56 GMT',824 },825 ],826 'referrer-policy': [827 {828 key: 'Referrer-Policy',829 value: 'no-referrer-when-downgrade',830 },831 ],832 server: [833 {834 key: 'Server',835 value: 'ExampleCustomOriginServer',836 },837 ],838 'x-content-type-options': [839 {840 key: 'X-Content-Type-Options',841 value: 'nosniff',842 },843 ],844 'x-frame-options': [845 {846 key: 'X-Frame-Options',847 value: 'DENY',848 },849 ],850 'x-xss-protection': [851 {852 key: 'X-XSS-Protection',853 value: '1; mode=block',854 },855 ],856 age: [857 {858 key: 'Age',859 value: '2402',860 },861 ],862 'content-type': [863 {864 key: 'Content-Type',865 value: 'text/html; charset=utf-8',866 },867 ],868 'content-length': [869 {870 key: 'Content-Length',871 value: '9593',872 },873 ],874 },875 status: '200',876 statusDescription: 'OK',877 },878 },879 },880 ],881 }882883 interface CloudFrontHeaders {884 [name: string]: [885 {886 key: string887 value: string888 },889 ]890 }891 let called = false892 let headers: CloudFrontHeaders = {}893 await handler(event, {}, (_err, result) => {894 if (result && result.headers) {895 headers = result.headers as CloudFrontHeaders896 }897 called = true898 })899900 expect(called).toBe(true)901 expect(headers['access-control-allow-credentials']).toEqual([902 {903 key: 'Access-Control-Allow-Credentials',904 value: 'true',905 },906 ])907 expect(headers['access-control-allow-origin']).toEqual([908 {909 key: 'Access-Control-Allow-Origin',910 value: '*',911 },912 ])913 })914915 it('Should handle a GET request and add header (Lambda@Edge viewer response)', async () => {916 const event = {917 Records: [918 {919 cf: {920 config: {921 distributionDomainName: 'example.com',922 distributionId: 'EDFDVBD6EXAMPLE',923 eventType: 'viewer-response',924 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',925 },926 request: {927 clientIp: '203.0.113.178',928 headers: {929 host: [930 {931 key: 'Host',932 value: 'example.com',933 },934 ],935 'user-agent': [936 {937 key: 'User-Agent',938 value: 'curl/7.66.0',939 },940 ],941 accept: [942 {943 key: 'accept',944 value: '*/*',945 },946 ],947 },948 method: 'GET',949 querystring: '',950 uri: '/header/add',951 },952 response: {953 headers: {954 'access-control-allow-credentials': [955 {956 key: 'Access-Control-Allow-Credentials',957 value: 'true',958 },959 ],960 'access-control-allow-origin': [961 {962 key: 'Access-Control-Allow-Origin',963 value: '*',964 },965 ],966 date: [967 {968 key: 'Date',969 value: 'Mon, 13 Jan 2020 20:14:56 GMT',970 },971 ],972 'referrer-policy': [973 {974 key: 'Referrer-Policy',975 value: 'no-referrer-when-downgrade',976 },977 ],978 server: [979 {980 key: 'Server',981 value: 'ExampleCustomOriginServer',982 },983 ],984 'x-content-type-options': [985 {986 key: 'X-Content-Type-Options',987 value: 'nosniff',988 },989 ],990 'x-frame-options': [991 {992 key: 'X-Frame-Options',993 value: 'DENY',994 },995 ],996 'x-xss-protection': [997 {998 key: 'X-XSS-Protection',999 value: '1; mode=block',1000 },1001 ],1002 age: [1003 {1004 key: 'Age',1005 value: '2402',1006 },1007 ],1008 'content-type': [1009 {1010 key: 'Content-Type',1011 value: 'text/html; charset=utf-8',1012 },1013 ],1014 'content-length': [1015 {1016 key: 'Content-Length',1017 value: '9593',1018 },1019 ],1020 },1021 status: '200',1022 statusDescription: 'OK',1023 },1024 },1025 },1026 ],1027 }10281029 interface CloudFrontHeaders {1030 [name: string]: [1031 {1032 key: string1033 value: string1034 },1035 ]1036 }1037 let called = false1038 let headers: CloudFrontHeaders = {}1039 await handler(event, {}, (_err, result) => {1040 if (result && result.headers) {1041 headers = result.headers as CloudFrontHeaders1042 }1043 called = true1044 })10451046 expect(called).toBe(true)1047 expect(headers['strict-transport-security']).toEqual([1048 {1049 key: 'Strict-Transport-Security',1050 value: 'max-age=63072000; includeSubdomains; preload',1051 },1052 ])1053 expect(headers['x-custom']).toEqual([1054 {1055 key: 'X-Custom',1056 value: 'Foo',1057 },1058 ])1059 })10601061 it('Callback Event (Lambda@Edge response)', async () => {1062 const event = {1063 Records: [1064 {1065 cf: {1066 config: {1067 distributionDomainName: 'example.com',1068 distributionId: 'EDFDVBD6EXAMPLE',1069 eventType: 'viewer-response',1070 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',1071 },1072 request: {1073 clientIp: '203.0.113.178',1074 headers: {1075 host: [1076 {1077 key: 'Host',1078 value: 'example.com',1079 },1080 ],1081 },1082 method: 'GET',1083 querystring: '',1084 uri: '/config/eventCheck',1085 },1086 },1087 },1088 ],1089 }10901091 let called = false1092 await handler(event, {}, () => {1093 called = true1094 })10951096 expect(called).toBe(true)1097 })10981099 it('Should return a response where bodyEncoding is "base64" with binary', async () => {1100 const event = {1101 Records: [1102 {1103 cf: {1104 config: {1105 distributionDomainName: 'example.com',1106 distributionId: 'EXAMPLE123',1107 eventType: 'viewer-request',1108 requestId: 'exampleRequestId',1109 },1110 request: {1111 clientIp: '123.123.123.123',1112 headers: {1113 host: [1114 {1115 key: 'Host',1116 value: 'example.com',1117 },1118 ],1119 },1120 method: 'GET',1121 querystring: '',1122 uri: '/binary',1123 },1124 },1125 },1126 ],1127 }11281129 const response = await handler(event)11301131 expect(response.body).toBe('RmFrZSBJbWFnZQ==') // base64 encoded "Fake Image"1132 expect(response.bodyEncoding).toBe('base64')1133 })1134})