mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-02-11 00:53:09 +00:00
Signed-off-by: Chrysostomos Nanakos <chris@include.gr> Co-authored-by: Chrysostomos Nanakos <chris@include.gr> Co-authored-by: gmega <giuliano.mega@gmail.com>
48 lines
1.6 KiB
Nim
48 lines
1.6 KiB
Nim
import std/times
|
|
import pkg/codex/conf
|
|
import pkg/stint
|
|
from pkg/libp2p import Cid, `$`
|
|
import ../../asynctest
|
|
import ../../checktest
|
|
import ../../examples
|
|
import ../../codex/examples
|
|
import ../codexconfig
|
|
import ../codexclient
|
|
import ../multinodes
|
|
|
|
multinodesuite "Rest API validation":
|
|
let config = NodeConfigs(clients: CodexConfigs.init(nodes = 1).some)
|
|
var client: CodexClient
|
|
|
|
setup:
|
|
client = clients()[0].client
|
|
|
|
test "should return 204 when attempting delete of non-existing dataset", config:
|
|
let data = await RandomChunker.example(blocks = 2)
|
|
let cid = (await client.upload(data)).get
|
|
|
|
let responseBefore = await client.deleteRaw($Cid.example)
|
|
check responseBefore.status == 204
|
|
check (await responseBefore.body) == "" # No content
|
|
|
|
test "upload fails if content disposition contains bad filename", config:
|
|
let headers = @[("Content-Disposition", "attachment; filename=\"exam*ple.txt\"")]
|
|
let response = await client.uploadRaw("some file contents", headers)
|
|
|
|
check response.status == 422
|
|
check (await response.body) == "The filename is not valid."
|
|
|
|
test "upload fails if content type is invalid", config:
|
|
let headers = @[("Content-Type", "hello/world")]
|
|
let response = await client.uploadRaw("some file contents", headers)
|
|
|
|
check response.status == 422
|
|
check (await response.body) == "The MIME type 'hello/world' is not valid."
|
|
|
|
test "has block returns error 400 when the cid is invalid", config:
|
|
let response = await client.hasBlockRaw("invalid-cid")
|
|
|
|
check:
|
|
response.status == 400
|
|
(await response.body) == "Incorrect Cid"
|