Important: there are changes here to adapt the tests and the Keycloak test realm that are incompatible with the changes in #29. Ultimately, the changes in #29 need to be applied over this.
4.5 KiB
Integration Testing
This directory contains infrastructure and tests to verify end-to-end operation of the provider.
Creating a Testing Keycloak
The Docker Compose setup in this directory sets up Keycloak and imports a realm testing.
Run docker compose up -d to start Keycloak. The admin console will be available at http://localhost:8080/.
You can attach a Java debugger at localhost:8081.
The realm export is in import/testing.json.
It will be imported automatically when Keycloak starts.
Updating the Realm
If you want to make changes to the testing realm and persist them, you need to export the realm.
The following command runs the Keycloak export for the realm testing storing it in the mapped directory import/testing.json.
The copying of the database is necessary to avoid locking errors.
env -i makes sure the regular environment variables are not set to avoid port conflicts.
docker compose exec -it keycloak sh -c "cp -rp /opt/keycloak/data/h2 /tmp && env -i -- /opt/keycloak/bin/kc.sh export --db dev-file --db-url 'jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE' --file /opt/keycloak/data/import/testing.json --realm testing"
Running Integration Tests
This directory contains shell scripts that exercise the attribute endpoint.
Bring up Keycloak with docker compose up -d, then run one of the client-test-export-*.sh scripts.
$ ./client-test-export-dooris.sh
All attributes collated into a single list
[
"hacker-ssh-key-1",
"hacker-ssh-key-2"
]
Results mapped per attribute
{
"ssh-key-1": [
"hacker-ssh-key-1"
],
"ssh-key-2": [
"hacker-ssh-key-2"
]
}
$ ./client-test-export-mailing-lists.sh
chaos@
[
"hacker+chaos@example.net",
"tester+chaos@example.com"
]
intern@
[
"hacker+intern@example.net"
]
Realm testing Configuration
The realm contains these objects:
- Clients:
export-dooris-ssh-keyswith secretexport-dooris-ssh-keys-secretand userservice-account-export-dooris-ssh-keysexport-mailing-list-addresseswith secretexport-mailing-list-addresses-secretand userservice-account-export-mailing-list-addresses
- Realm Roles:
dooris-authorizedto assign to users whose SSH keys should be exportedmailing-list-chaos-memberto assign to users who are a member of the chaos mailing listmailing-list-intern-memberto assign to users who are a member of the intern mailing listexport-dooris-ssh-keysto assign to service account users that should be allowed to use the dooris endpoint configexport-mailing-list-addressesto assign to service account users that should be allowed to use the mailing list endpoint configs
- Groups:
chaoswith rolemailing-list-chaos-memberìnternwith rolesdooris-authorized,mailing-list-chaos-memberandmailing-list-intern-member
- Users:
tester(Tony Tester), emailtester@example.com, member of groupchaos- Mailing List Addresses:
- Chaos:
tester+chaos@example.com - Intern:
tester+intern@example.com
- Chaos:
- Dooris SSH Keys:
- SSH Key 1:
tester-ssh-key-1 - SSH Key 2:
tester-ssh-key-2
- SSH Key 1:
- Mailing List Addresses:
hacker(Hans Acker), emailhacker@example.net, member of groupschaosandintern- Mailing List Addresses:
- Chaos:
hacker+chaos@example.net - Intern:
hacker+intern@example.net
- Chaos:
- Dooris SSH Keys:
- SSH Key 1:
hacker-ssh-key-1 - SSH Key 2:
hacker-ssh-key-2
- SSH Key 1:
- Mailing List Addresses:
service-account-export-dooris-ssh-keys- Role
export-dooris-ssh-keys
- Role
service-account-export-mailing-list-addresses- Role
export-mailing-list-addresses
- Role
- Realm Settings:
- User Profile:
- Attribute Groups:
dooris-ssh-keysmailing-list-addresses
- Attributes:
mailing-list-address-chaos- Attribute Group
mailing-list-addresses
- Attribute Group
mailing-list-address-intern- Attribute Group
mailing-list-addresses
- Attribute Group
ssh-key-1- Attribute Group
dooris-ssh-keys
- Attribute Group
ssh-key-2- Attribute Group
dooris-ssh-keys
- Attribute Group
- Attribute Groups:
- User Profile:
- Custom Attributes:
- Slug
dooris-ssh-keys- Attribute Group
dooris-ssh-keys - Match Role
dooris-authorized - Auth Role
export-dooris-ssh-keys
- Attribute Group
- Slug
mailing-list-addresses-chaos- Attribute Group
mailing-list-addresses - Match Role
mailing-list-chaos-member - Auth Role
export-mailing-list-addresses
- Attribute Group
- Slug
mailing-list-addresses-intern- Attribute Group
mailing-list-addresses - Match Role
mailing-list-intern-member - Auth Role
export-mailing-list-addresses
- Attribute Group
- Slug