# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           npm 1.0

name                azurite
version             3.37.0
revision            0
categories          devel
license             MIT
platforms           any
supported_archs     noarch
maintainers         {@jrjsmrtn gmail.com:jrjsmrtn} openmaintainer

description         emulator for Azure Blob, Queue and Table storage
long_description    Azurite is Microsoft's local emulator for Azure Storage. \
                    It serves the Blob, Queue and Table service APIs, for \
                    developing and testing code that uses Azure Storage \
                    without an Azure account.

homepage            https://github.com/Azure/Azurite

checksums           rmd160  daf834aa11f0bd81cb36bc290d53a58645b2238f \
                    sha256  991f93cbfd9006d61f8708a7ff78f4f76ce90ff8ee1dfb76ba47de2323170065 \
                    size    873420

# Start the blob service on loopback and send it an anonymous request: an
# Azure Storage AuthorizationFailure shows the service answering, not just a
# port being open. --noproxy: MacPorts exports a configured proxy_http, which
# would otherwise get the loopback request.
test.run            yes
test {
    set port 10199
    set data ${workpath}/test-data
    file mkdir ${data}
    set pid [exec ${destroot}${prefix}/bin/azurite-blob --blobHost 127.0.0.1 \
        --blobPort ${port} --location ${data} --silent >& ${workpath}/test.log &]
    set reply ""
    for {set i 0} {$i < 50 && ![string match *AuthorizationFailure* ${reply}]} {incr i} {
        after 200
        catch {set reply [exec /usr/bin/curl -s --noproxy * http://127.0.0.1:${port}/devstoreaccount1?comp=list]}
    }
    catch {exec kill ${pid}}
    if {![string match *AuthorizationFailure* ${reply}]} {
        return -code error "azurite-blob did not answer as Azure Storage on port ${port}"
    }
    ui_info "azurite-blob answered on port ${port}: AuthorizationFailure, as expected"
}
