suite: Controller Additional Existing Secrets
release:
  name: my-release
  namespace: my-namespace
templates:
  - jenkins-controller-statefulset.yaml
  - config.yaml
tests:
  - it: test additional existing secrets StatefulSet
    template: jenkins-controller-statefulset.yaml
    set:
      controller.additionalExistingSecrets:
        - name: "{{ .Release.Name }}-secret"
          keyName: username
        - name: "{{ .Release.Name }}-secret"
          keyName: password
      controller.existingSecret: my-existing-credentials

    asserts:
      - isKind:
          of: StatefulSet
      - equal:
          path: spec.template.spec.containers[0].volumeMounts[4]
          value:
            mountPath: /run/secrets/additional
            name: jenkins-secrets
            readOnly: true
      - equal:
          path: spec.template.spec.volumes[3]
          value:
            name: jenkins-secrets
            projected:
              sources:
                - secret:
                    name: my-release-secret
                    items:
                      - key: username
                        path: my-release-secret-username
                - secret:
                    name: my-release-secret
                    items:
                      - key: password
                        path: my-release-secret-password
                - secret:
                    name: my-release-jenkins
                    items:
                      - key: jenkins-admin-user
                        path: chart-admin-username
                      - key: jenkins-admin-password
                        path: chart-admin-password
                - secret:
                    name: my-existing-credentials
