{"id":21726968,"url":"https://github.com/wttech/apmt","last_synced_at":"2025-06-22T10:33:16.127Z","repository":{"id":54787174,"uuid":"185188704","full_name":"wttech/apmt","owner":"wttech","description":"AEM Permission Matrix Tester","archived":false,"fork":false,"pushed_at":"2021-01-29T09:05:54.000Z","size":244,"stargazers_count":4,"open_issues_count":4,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-12T23:33:50.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wttech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-06T12:05:01.000Z","updated_at":"2021-01-29T09:05:56.000Z","dependencies_parsed_at":"2022-08-14T03:00:25.920Z","dependency_job_id":null,"html_url":"https://github.com/wttech/apmt","commit_stats":null,"previous_names":["cognifide/apmt"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/wttech/apmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wttech%2Fapmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wttech%2Fapmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wttech%2Fapmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wttech%2Fapmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wttech","download_url":"https://codeload.github.com/wttech/apmt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wttech%2Fapmt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261278534,"owners_count":23134708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T03:42:32.301Z","updated_at":"2025-06-22T10:33:11.102Z","avatar_url":"https://github.com/wttech.png","language":"Kotlin","readme":"![WTT logo](docs/wtt-logo.png)\n\n[![Build Status](https://travis-ci.org/Cognifide/APMT.svg?branch=master)](https://travis-ci.org/Cognifide/APMT)\n[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/cognifide/apmt.svg?label=License)](http://www.apache.org/licenses/)\n\n# APMT\n\nAPMT (**A**EM **P**ermission **M**atrix **T**ester) is a tool which speeds up creation of permission tests for application built on top of AEM. \n\n## References\n* [REST-assured 4](http://rest-assured.io/)\n* [JUnit 5](https://junit.org/junit5/)\n\n## Getting started\nAPMT requires `apmt.yaml` file, which provides data about admin user, and author and publish instances. Admin doesn't need to be exactly admin user, but it must be the user, who is able to perform all tested actions, and revert them. So when you want to test creation of pages, admin must be able to create page under provided path, and also to delete it. \n ```yaml\n# Instance configuration\n---\napmt-user:\n  username: admin\n  password: admin\ninstances:\n  author:\n    name: author@local\n    url: http://localhost:8080\n    headers: # additional headers sent to server in all requests \n      apmt-header1: apmt-value1\n      apmt-header2: apmt-value2\n  publish:\n    name: publish@local\n    url: http://localhost:8080\n    headers:\n      apmt-header1: apmt-value1\n      apmt-header2: apmt-value2\n```\nThe next thing required by APMT is list of users.\n```kotlin\npackage com.cognifide.apmt.tests\n\nimport com.cognifide.apmt.User\n\nenum class Users(\n    override val username: String,\n    override val password: String\n) : User {\n    USER(\"user\", \"password\"),\n    AUTHOR(\"author\", \"password\"),\n    SUPER_AUTHOR(\"super-author\", \"password\")\n}\n```\nFinally, you can add permissions tests. Here is more complicated example, test which creates a page.\n```kotlin\npackage com.cognifide.apmt.tests\n\nimport com.cognifide.apmt.BasicTestCase\n\nclass CreatePageTest : com.cognifide.apmt.tests.page.CreatePageTest(\n    BasicTestCase {\n        paths(\n            \"/content/my-site/en_us/home\",\n            \"/content/my-site/de_de/home\"\n        )\n        allowedUsers(\n            Users.AUTHOR,\n            Users.SUPER_AUTHOR\n        )\n    },\n    pageContent = {\n        jcrTitle = \"Example Page\"\n        slingResourceType = \"apmt/components/testPage\"\n        cqTemplate = \"apmt/templates/testPage\"\n\n        \"apmtType\" set \"apmtTestPage\"\n    }\n)\n```\nAnd the simplest example, test which opens a page. \n```kotlin\npackage com.cognifide.apmt.tests\n\nimport com.cognifide.apmt.BasicTestCase\n\nclass OpenPageTest : com.cognifide.apmt.tests.page.OpenPageTest(\n    BasicTestCase {\n        paths(\n          \"/content/my-site/en_us/home\",\n          \"/content/my-site/en_us/home\"\n        )\n        allowedUsers(\n          *Users.values()\n        )\n    }\n)\n```\n### Alternative enum driven approach\nInstead of defining tests cases directly in test class, you may use enum class to define them.\n```kotlin\npackage com.cognifide.apmt.tests\n\nimport com.cognifide.apmt.TestCase\n\nenum class TestCases(private initConfig: TestCase.() -\u003e Unit) : TestCase {\n\n    CREATE_PAGE({\n        paths(\n            \"/content/my-site/en_us/home\",\n            \"/content/my-site/de_de/home\"\n        )\n        allowedUsers(\n            Users.AUTHOR,\n            Users.SUPER_AUTHOR\n        )\n    }),\n    OPEN_PAGE({\n        paths(\n            \"/content/my-site/en_us/home\",\n            \"/content/my-site/en_us/home\"\n        )\n        allowedUsers(\n            *Users.values()\n        )\n    });\n\n    override var allowedUsers: List\u003cUser\u003e = listOf()\n    override var deniedUsers: List\u003cUser\u003e = listOf()\n    override var paths: List\u003cString\u003e = listOf()\n    override var allUsers: List\u003cUser\u003e = listOf()\n    override var allowedPairsPredicate: ((user: User, path: String) -\u003e Boolean)? = null\n    override var deniedPairsPredicate: ((user: User, path: String) -\u003e Boolean)? = null\n\n    init {\n        this.apply(initConfig)\n        this.allUsers(ApmtUsers.values())\n    }\n}\n```\nAnd here is test class which uses this enum:\n```kotlin\npackage com.cognifide.apmt.tests\n\nclass CreatePageTest : com.cognifide.apmt.tests.page.CreatePageTest(\n    TestCases.CREATE_PAGE,\n    pageContent = {\n        jcrTitle = \"Example Page\"\n        slingResourceType = \"apmt/components/testPage\"\n        cqTemplate = \"apmt/templates/testPage\"\n\n        \"apmtType\" set \"apmtTestPage\"\n    }\n)\n```\n## How does it work?\nLet's look at the `CREATE_TEST` case (it's a little bit modified).\n```kotlin\nCREATE_PAGE({\n    paths(\n        \"/content/my-site/en_us/home\",\n        \"/content/my-site/de_de/home\"\n    )\n    allowedUsers(\n        Users.AUTHOR,\n        Users.SUPER_AUTHOR\n    )\n    allUsers(\n        *Users.values()\n    )\n})\n```\nCreatePageTest will be executed for each pair of user and path, and users will be spllited for 2 groups:\n* Allowed users - users with access to create pages (explicitly defined in section `allowedUsers`),\n* Denied users - users without the access (users defined in `allUsers` without the users from `allowedUsers`). \n\nFor each group will be executed different test method.\n\n| Access | User | Path |\n| --- | :---: | :---: |\n| Denied | USER | /content/my-site/en_us/home |\n| Denied | USER | /content/my-site/de_de/home |\n| Allowed | AUTHOR | /content/my-site/en_us/home |\n| Allowed | AUTHOR | /content/my-site/de_de/home |\n| Allowed | SUPER_AUTHOR | /content/my-site/de_de/home |\n| Allowed | SUPER_AUTHOR | /content/my-site/de_de/home |\n\nYou can use 3 sections to define users groups:\n* `allowedUsers` define users who can perform action\n* `deniedUsers` define users who can not perform action\n* `allUsers` used to compute not defined group\n```kotlin\nallowedUsers(\n    Users.AUTHOR,\n    Users.SUPER_AUTHOR\n)\ndeniedUsers(\n    Users.USER\n)   \nallUsers(\n    *Users.values()\n)\n```\n\nHere is table which shows how sections are used to define final groups.  \n\n| `allowedUsers` | `deniedUsers` | `allUsers` | Allowed users | Denied users | \n| --- | :---: | :---: | --- | --- |\n| definied | | | allowedUser | |\n| definied | | defined | allowedUser | allUsers - allowedUsers |\n| definied | defined | | allowedUser | deniedUsers |\n| | defined | | | deniedUsers|\n| | defined | defined | allUsers - deniedUsers | deniedUsers |\n\nYou don't need to define `allUsers` explicitly in each test case. You may define all users in overridden method `toTestCaseConfiguration()`. \n```kotlin\noverride fun toTestCaseConfiguration(): TestCaseConfiguration {\n    val testCaseConfiguration = TestCaseConfiguration().apply(initConfig)\n    testCaseConfiguration.allUsers(Users.values())\n    return testCaseConfiguration\n}\n```\n\n## Unit tests\n\nIf you have some problems with specific tests you can take a look on unit tests which are located in this repository in `com.cognifide.apmt.tests` package. \nPlease mind that you are interested only in constructor part.\n\n## License\n**APM** is licensed under [Apache License, Version 2.0 (the \"License\")](https://www.apache.org/licenses/LICENSE-2.0.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwttech%2Fapmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwttech%2Fapmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwttech%2Fapmt/lists"}