{"id":19199798,"url":"https://github.com/libresign/nextcloud-behat","last_synced_at":"2026-02-16T23:47:31.103Z","repository":{"id":62549596,"uuid":"486648812","full_name":"LibreSign/nextcloud-behat","owner":"LibreSign","description":"Basic steps for a Nextcloud app","archived":false,"fork":false,"pushed_at":"2025-02-27T19:43:08.000Z","size":333,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T11:31:59.490Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LibreSign.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-28T15:25:15.000Z","updated_at":"2025-02-27T19:42:24.000Z","dependencies_parsed_at":"2024-04-05T21:25:55.142Z","dependency_job_id":"9cc02082-a7ce-48b2-bd92-05571bd57002","html_url":"https://github.com/LibreSign/nextcloud-behat","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":"0.30000000000000004","last_synced_commit":"c47819cd7d70a0bfaa5806e9b6f01c3d597be246"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LibreSign%2Fnextcloud-behat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LibreSign%2Fnextcloud-behat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LibreSign%2Fnextcloud-behat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LibreSign%2Fnextcloud-behat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LibreSign","download_url":"https://codeload.github.com/LibreSign/nextcloud-behat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253172872,"owners_count":21865576,"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":["hacktoberfest"],"created_at":"2024-11-09T12:29:01.271Z","updated_at":"2026-02-16T23:47:31.091Z","avatar_url":"https://github.com/LibreSign.png","language":"PHP","readme":"# Nextcloud Behat context\n\nBasic Behat steps for a Nextcloud app\n\n## Install\n\n```bash\ncomposer require --dev libresign/nextcloud-behat\n```\nCreate the file `behat.yml`\n```yaml\ndefault:\n  autoload:\n    '': '%paths.base%/features/bootstrap'\n  suites:\n    default:\n      contexts:\n        - Libresign\\NextcloudBehat\\NextcloudApiContext:\n            parameters:\n              # default value\n              test_password: 123456\n              # default value\n              admin_password: admin\n      # Only necessary if you want to have a different features folder\n      paths:\n        - '%paths.base%/features'\n  extensions:\n    # Use this extension to start the server\n    PhpBuiltin\\Server:\n      verbose: false\n      rootDir: /var/www/html\n      host: localhost\n```\nCreate the file `tests/features/bootstrap/FeatureContext.php` with this content:\n```php\n\u003c?php\n\nuse Libresign\\NextcloudBehat;\n\nclass FeatureContext extends NextcloudApiContext {\n\n}\n```\n\nThen, now you can see all available steps:\n```bash\nvendor/bin/behat -dl\n```\n\n```gherkin\nGiven as user :user\nGiven user :user exists\nGiven sending :verb to :url\nGiven the response should be a JSON array with the following mandatory values\nGiven guest :guest exists\nGiven /^set the display name of user \"([^\"]*)\" to \"([^\"]*)\"$/\nGiven /^set the email of user \"([^\"]*)\" to \"([^\"]*)\"$/\nGiven sending :verb to ocs :url\nGiven /^set the custom http header \"([^\"]*)\" with \"([^\"]*)\" as value to next request$/\nGiven the response should have a status code :code\nGiven fetch field :path from previous JSON response\nGiven the response should contain the initial state :name with the following values:\nGiven the response should contain the initial state :name json that match with:\nGiven the following :appId app config is set\nGiven /^run the command \"(?P\u003ccommand\u003e(?:[^\"]|\\\")*)\"$/\nGiven the output of the last command should contain the following text:\nGiven the output of the last command should be empty\nGiven /^run the command \"(?P\u003ccommand\u003e(?:[^\"]|\\\")*)\" with result code (\\d+)$/\nGiven /^run the bash command \"(?P\u003ccommand\u003e(?:[^\"]|\\\")*)\" with result code (\\d+)$/\nGiven create an environment :name with value :value to be used by occ command\nGiven /^wait for ([0-9]+) (second|seconds)$/\nGiven /^past ([0-9]+) (second|seconds) since wait step$/\n```\n\n## Tips\n\n### Value as string\nTo send a json value as string, prefix the json string with (string)\n\n**Example**:\n```gherkin\nGiven sending \"post\" to ocs \"/apps/provisioning_api/api/v1/config/apps/appname/propertyname\"\n  | value | (string){\"enabled\":true} |\n```\n\n### Value as array\nTo send a value as array, you can set a json string and the json string will be converted to array\n\n**Example**:\n```gherkin\nGiven sending \"post\" to ocs \"/apps/libresign/api/v1/request-signature\"\n  | status | 1 |\n  | file   | {\"base64\":\"\"} |\n```\n\n### Step: all steps that run commands\n\nBefore the command is executed, the following placeholders will be replaced:\n\n| Placeholder          | Value                  |\n| -------------------- | ---------------------- |\n| `\u003cappRootDir\u003e`       | your app root dir      |\n| `\u003cnextcloudRootDir\u003e` | The Nextcloud root dir |\n\n### Step: `fetch field :path from previous JSON response`\n\nIf the json response is an array, you can fetch specific values using this step. The fetched values is stored to be used by other steps.\n\n`:path`: Path is  a selector to retrieves a value from a deeply nested array using \"dot\" notation:\n\nTo the follow json:\n```json\n{\"products\":{\"desk\":{\"price\":100}}}\n```\npath need to be: products.desk.price\n\nYou also can prefix the path by an alias inside parenthesis:\n\n(price)products.desk.price\n\nThe alias `price` could be used in a path or body of a request:\n```gherkin\n  When set the response to:\n    \"\"\"\n    {\n      \"data\": [\n        {\n          \"foo\":\"bar\"\n        }\n      ]\n    }\n    \"\"\"\n  And sending \"POST\" to \"/\"\n  And fetch field \"(foo)data.0.foo\" from previous JSON response\n  # After fetch the field, you can use the value of field like this:\n  And sending \"POST\" to \"/?foo=\u003cfoo\u003e\"\n    | field | \u003cdata.0.foo\u003e |\n```\n\n#### Fetch field using jq\n\nYou can assign the return of a jq to your field using a jq like as the follow pattern:\n\n```gherkin\nAnd fetch field \"(foo)(jq).value\" from previous JSON response\n```\n\nThis will retrieve a specific value from json response and assign this to your desided field.\n\n## Parse response using jq\n\nYou can use [jq](https://jqlang.github.io/jq/manual/) expression casting to check a value in a json response body of a request. To do this you will need to install the jq command.\n\nExample:\n\n```gherkin\nGiven set the response to:\n  \"\"\"\n  {\n    \"Foo\": {\n      \"Bar\": \"33\"\n    }\n  }\n  \"\"\"\nAnd sending \"POST\" to \"/\"\nThen the response should be a JSON array with the following mandatory values\n  | key          | value            |\n  | Foo          | (jq).Bar == \"33\" |\n  | (jq).Foo     | {\"Bar\":\"33\"}     |\n  | (jq).Foo     | (jq).Bar == \"33\" |\n  | (jq).Foo.Bar | 33               |\n```\n\n## Parse text\n\nIf you need to:\n- Get values from a request, store and use in other request\n- Parse the response of a request\n\nImplement a method `parseText` like the follow code and remember to call parent method.\n\nThis methods can works together with `fetch field :path from previous JSON response`\n```php\nprotected function parseText(string $text): string {\n  $patterns = [\n    '/\u003cSIGN_UUID\u003e/',\n    '/\u003cFILE_UUID\u003e/',\n  ];\n  $replacements = [\n    $this-\u003esigner['sign_uuid'] ?? null,\n    $this-\u003efile['uuid'] ?? $this-\u003egetFileUuidFromText($text),\n  ];\n  $text = preg_replace($patterns, $replacements, $text);\n  $text = parent::parseText($text);\n  return $text;\n}\n```\nFor more information about parseText, check the scenario `Test get field from json response`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibresign%2Fnextcloud-behat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibresign%2Fnextcloud-behat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibresign%2Fnextcloud-behat/lists"}