github.com/containers/podman/v5@v5.1.0-rc1/test/apiv2/50-secrets.at (about)

     1  # -*- sh -*-
     2  #
     3  # secret-related tests
     4  #
     5  
     6  # secret create
     7  t POST secrets/create Name=mysecret Data=c2VjcmV0 200\
     8      .ID~.* \
     9  
    10  # secret create name already in use
    11  t POST secrets/create Name=mysecret Data=c2VjcmV0 409
    12  
    13  # secret inspect
    14  t GET secrets/mysecret 200 \
    15      .Spec.Name=mysecret \
    16      .Version.Index=1
    17  
    18  # secret inspect non-existent secret
    19  t GET secrets/bogus 404
    20  
    21  # Check exists with existing secret
    22  t GET libpod/secrets/mysecret/exists 204
    23  
    24  # Check exists for non-existing secret
    25  t GET libpod/secrets/bogus/exists 404
    26  
    27  # secret list
    28  t GET secrets 200 \
    29      length=1 \
    30      .[0].Spec.Name=mysecret \
    31      .[0].Version.Index=1
    32  
    33  # secret list with filters
    34  t GET secrets?filters='{"name":["mysecret"]}' 200 \
    35      length=1 \
    36      .[0].Spec.Name=mysecret \
    37      .[0].Version.Index=1
    38  
    39  t GET secrets?filters='{"name":["mysecret2"]}' 200 \
    40      length=0 \
    41  
    42  # secret libpod list with filters
    43  t GET libpod/secrets/json?filters='{"name":["mysecret"]}' 200 \
    44      length=1 \
    45      .[0].Spec.Name=mysecret \
    46  
    47  t GET libpod/secrets/json?filters='{"name":["mysecret2"]}' 200 \
    48      length=0 \
    49  
    50  # secret list with unsupported filters
    51  t GET secrets?filters='{"label":["xyz"]}' 500
    52  
    53  #compat api list secrets sanity checks
    54  t GET secrets?filters='garb1age}' 500 \
    55      .cause="invalid character 'g' looking for beginning of value"
    56  t GET secrets?filters='{"label":["testl' 500 \
    57      .cause="unexpected end of JSON input"
    58  
    59  #libpod api list secrets sanity checks
    60  t GET libpod/secrets/json?filters='garb1age}' 500 \
    61      .cause="invalid character 'g' looking for beginning of value"
    62  t GET libpod/secrets/json?filters='{"label":["testl' 500 \
    63      .cause="unexpected end of JSON input"
    64  
    65  # secret with labels
    66  t POST secrets/create Name=labeledsecret Data=c2VjcmV0 Labels='{"foo":"bar"}' 200
    67  t GET secrets/labeledsecret 200 \
    68      .Spec.Labels.foo=bar
    69  
    70  # secret rm
    71  t DELETE secrets/mysecret 204
    72  t DELETE secrets/labeledsecret 204
    73  
    74  # secret rm non-existent secret
    75  t DELETE secrets/bogus 404
    76  
    77  # secret update not implemented
    78  t POST secrets/mysecret/update 501