apiVersion: v1
kind: ConfigMap
metadata:
  name: keycloak-realm
data:
  test-realm.json: |
    {
      "realm": "test-realm",
      "enabled": true,
      "sslRequired": "none",
      "roles": {
        "realm": [
          {
            "name": "test-user-role"
          },
          {
            "name": "test-admin-role"
          }
        ]
      },
      "users": [
        {
          "username": "test-normal-user",
          "enabled": true,
          "credentials": [
            {
              "type": "password",
              "value": "test-normal-user"
            }
          ],
          "realmRoles": [
            "test-user-role"
          ]
        },
        {
          "username": "test-admin-user",
          "enabled": true,
          "credentials": [
            {
              "type": "password",
              "value": "test-admin-user"
            }
          ],
          "realmRoles": [
            "test-admin-role",
            "test-user-role"
          ]
        }
      ],
      "clients": [
        {
          "clientId": "test-application-client",
          "enabled": true,
          "protocol": "openid-connect",
          "standardFlowEnabled": false,
          "implicitFlowEnabled": false,
          "directAccessGrantsEnabled": true,
          "clientAuthenticatorType": "client-secret",
          "secret": "test-application-client-secret",
          "authorizationSettings": {
            "resources": [
              {
                "name": "test-user-resource",
                "uris": [
                  "/user/*"
                ]
              },
              {
                "name": "test-admin-resource",
                "uris": [
                  "/admin/*"
                ]
              }
            ],
            "policies": [
              {
                "name": "test-user-policy",
                "type": "role",
                "config": {
                  "roles": "[{\"id\":\"test-user-role\",\"required\":true}]"
                }
              },
              {
                "name": "test-admin-policy",
                "type": "role",
                "config": {
                  "roles": "[{\"id\":\"test-admin-role\",\"required\":true}]"
                }
              },
              {
                "name": "test-user-permission",
                "type": "resource",
                "config": {
                  "resources": "[\"test-user-resource\"]",
                  "applyPolicies": "[\"test-user-policy\"]"
                }
              },
              {
                "name": "test-admin-permission",
                "type": "resource",
                "config": {
                  "resources": "[\"test-admin-resource\"]",
                  "applyPolicies": "[\"test-admin-policy\"]"
                }
              }
            ]
          }
        }
      ]
    }
