github.com/argoproj/argo-cd@v1.8.7/cmd/argocd-util/commands/secrets_redactor_test.go (about)

     1  package commands
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  var textToRedact = `
    10  connectors:
    11  - config:
    12      clientID: aabbccddeeff00112233
    13      clientSecret: |
    14        theSecret
    15      orgs:
    16      - name: your-github-org
    17      redirectURI: https://argocd.example.com/api/dex/callback
    18    id: github
    19    name: GitHub
    20    type: github
    21  - config:
    22      bindDN: uid=serviceaccount,cn=users,dc=example,dc=com
    23      bindPW: theSecret
    24      host: ldap.example.com:636
    25    id: ldap
    26    name: LDAP
    27    type: ldap
    28  grpc:
    29    addr: 0.0.0.0:5557
    30  telemetry:
    31    http: 0.0.0.0:5558
    32  issuer: https://argocd.example.com/api/dex
    33  oauth2:
    34    skipApprovalScreen: true
    35  staticClients:
    36  - id: argo-cd
    37    name: Argo CD
    38    redirectURIs:
    39    - https://argocd.example.com/auth/callback
    40    secret: Dis9M-GA11oTwZVQQWdDklPQw-sWXZkWJFyyEhMs
    41  - id: argo-cd-cli
    42    name: Argo CD CLI
    43    public: true
    44    redirectURIs:
    45    - http://localhost
    46  storage:
    47    type: memory
    48  web:
    49    http: 0.0.0.0:5556`
    50  
    51  var expectedRedaction = `connectors:
    52  - config:
    53      clientID: aabbccddeeff00112233
    54      clientSecret: '********'
    55      orgs:
    56      - name: your-github-org
    57      redirectURI: https://argocd.example.com/api/dex/callback
    58    id: github
    59    name: GitHub
    60    type: github
    61  - config:
    62      bindDN: uid=serviceaccount,cn=users,dc=example,dc=com
    63      bindPW: '********'
    64      host: ldap.example.com:636
    65    id: ldap
    66    name: LDAP
    67    type: ldap
    68  grpc:
    69    addr: 0.0.0.0:5557
    70  issuer: https://argocd.example.com/api/dex
    71  oauth2:
    72    skipApprovalScreen: true
    73  staticClients:
    74  - id: argo-cd
    75    name: Argo CD
    76    redirectURIs:
    77    - https://argocd.example.com/auth/callback
    78    secret: '********'
    79  - id: argo-cd-cli
    80    name: Argo CD CLI
    81    public: true
    82    redirectURIs:
    83    - http://localhost
    84  storage:
    85    type: memory
    86  telemetry:
    87    http: 0.0.0.0:5558
    88  web:
    89    http: 0.0.0.0:5556
    90  `
    91  
    92  func TestSecretsRedactor(t *testing.T) {
    93  	assert.Equal(t, expectedRedaction, redactor(textToRedact))
    94  }