# Test Outbox Object Wrapping Requirements

An activitypub-testing issue.

## Goal

Add a test rule that tests the requirements from ["6.2.1 Object creation without a Create Activity"](https://www.w3.org/TR/activitypub/#object-without-create), e.g.

* > The server then MUST attach this object as the object of a Create Activity.
    * aka [`urn:uuid:e6d00349-6d07-4512-9a99-f698d3bc1dba`](https://activitypub-testing.socialweb.coop/e6d00349-6d07-4512-9a99-f698d3bc1dba)
* > For non-transient objects, the server MUST attach an id to both the wrapping Create and its wrapped Object.
    * aka [`urn:uuid:104e2cde-f072-43af-badd-bf9bd4129151`](https://activitypub-testing.socialweb.coop/104e2cde-f072-43af-badd-bf9bd4129151)
* > Any to, bto, cc, bcc, and audience properties specified on the object MUST be copied over to the new Create activity by the server.
    * aka [`urn:uuid:f3725db1-1e6b-4d20-9cea-a49ef4291e9f`](https://activitypub-testing.socialweb.coop/f3725db1-1e6b-4d20-9cea-a49ef4291e9f)

## Decisions

* one test or many?
    * start with one and see how it goes
* test case slug
    * `outbox-wraps-object-with-create-checked-using-get-location`

## Acceptance Criteria

* for each new test e.g. slug=`outbox-wraps-object-with-create-checked-using-get-location`
  * i can see the test case
    * in the index at https://activitypub-testing.socialweb.coop/test-cases/
    * in detail at `https://activitypub-testing.socialweb.coop/test-cases/{slug}`
  * i can see an example invocation that passes

## Tests

* [outbox-wraps-object-with-create-checked-using-get-location.js](../src/activitypub-tests/outbox-wraps-object-with-create-checked-using-get-location/outbox-wraps-object-with-create-checked-using-get-location.js)
  * AC
    * [x] in [index](https://activitypub-testing.socialweb.coop/test-cases/) as "Outbox Wraps Object With Create Activity"
    * [x] has test detail page https://activitypub-testing.socialweb.coop/test-cases/outbox-wraps-object-with-create-checked-using-get-location
      * but it's using the default template which doesn't show as much as test cases that do have their own markdown. Can/should be improved.
    * [x] release to npm a version of activitypub-testing with this test
    * [x] sample invocation
      * [x] with fully released activitypub-testing
      * [x] working in prerelease cli. see example below.
      * [x] ensure `run test` cli command respects HiddenInTestResults type on input.authorization ([activitypub-testing@0.12.0](../CHANGELOG.md#0-12-0))

## Examples

requires [`activitypub-testing@0.11.0`](https://codeberg.org/socialweb.coop/activitypub-testing/src/tag/activitypub-testing@0.11.0/CHANGELOG.md#0-11-0)

### testing https://socialweb.coop

```shell
⚡ activitypub-testing run test \
  --slug outbox-wraps-object-with-create-checked-using-get-location \
  --input.outbox='https://socialweb.coop/outbox'
{
  "type": "Assertion",
  "test": {
    "id": "urn:uuid:963a2313-788e-4bb7-b6ea-0d8bf7d255ef",
    "uuid": "963a2313-788e-4bb7-b6ea-0d8bf7d255ef",
    "url": "https://socialweb.coop/activitypub/test-cases/outbox-wraps-object-with-create-checked-using-get-location/",
    "slug": "outbox-wraps-object-with-create-checked-using-get-location"
  },
  "input": {
    "outbox": "https://socialweb.coop/outbox"
  },
  "result": {
    "outcome": "passed"
  },
  "@context": [
    "https://socialweb.coop/ns/testing/context.json",
    "https://www.w3.org/ns/activitystreams"
  ]
}
```

### testing https://onepage.pub/person/qfU45YyW4aDIG-lN_lHSS

#### without authorization

```shell
activitypub-testing run test \
  --slug outbox-wraps-object-with-create-checked-using-get-location \
  --input.outbox='https://onepage.pub/orderedcollection/VXH9LQd6l8pm015WyWyA7'
{
  "type": "Assertion",
  "test": {
    "id": "urn:uuid:963a2313-788e-4bb7-b6ea-0d8bf7d255ef",
    "uuid": "963a2313-788e-4bb7-b6ea-0d8bf7d255ef",
    "url": "https://socialweb.coop/activitypub/test-cases/outbox-wraps-object-with-create-checked-using-get-location/",
    "slug": "outbox-wraps-object-with-create-checked-using-get-location",
    "requirementReference": [
      {
        "id": "urn:uuid:e6d00349-6d07-4512-9a99-f698d3bc1dba",
        "url": "https://activitypub-testing.socialweb.coop/e6d00349-6d07-4512-9a99-f698d3bc1dba"
      },
      {
        "id": "urn:uuid:104e2cde-f072-43af-badd-bf9bd4129151",
        "url": "https://activitypub-testing.socialweb.coop/104e2cde-f072-43af-badd-bf9bd4129151"
      },
      {
        "id": "urn:uuid:f3725db1-1e6b-4d20-9cea-a49ef4291e9f",
        "url": "https://activitypub-testing.socialweb.coop/f3725db1-1e6b-4d20-9cea-a49ef4291e9f"
      }
    ]
  },
  "input": {
    "outbox": "https://onepage.pub/orderedcollection/VXH9LQd6l8pm015WyWyA7"
  },
  "result": {
    "outcome": "inapplicable",
    "pointer": {
      "request": {
        "url": "https://onepage.pub/orderedcollection/VXH9LQd6l8pm015WyWyA7"
      },
      "response": {
        "status": 403,
        "statusText": "Forbidden"
      }
    },
    "info": "expected outbox post response to have an http header named 'location', but there is none. This test only applies to servers that do."
  },
  "@context": [
    "https://socialweb.coop/ns/testing/context.json",
    "https://www.w3.org/ns/activitystreams"
  ]
}%
```

#### with authorization

use [activitypub-testing@0.12.0](../CHANGELOG.md#0-12-0) to ensure authorization input is hidden in test results

```shell
⚡ activitypub-testing run test \
  --slug outbox-wraps-object-with-create-checked-using-get-location \
  --input.outbox='https://onepage.pub/orderedcollection/VXH9LQd6l8pm015WyWyA7' \
  --input.authorization="Bearer `cat ~/.activitypub-testing/bengo_onepagepub_token`"
{
  "type": [
    "Assertion"
  ],
  "result": {
    "outcome": "passed"
  },
  "test": {
    "slug": "outbox-wraps-object-with-create-checked-using-get-location",
    "description": "a test rule that submits an object to an outbox and checks for conformance with requirements for how the outbox server must wrap the object in a Create Activity.",
    "name": "Outbox Wraps Object With Create Activity",
    "id": "urn:uuid:963a2313-788e-4bb7-b6ea-0d8bf7d255ef",
    "requirementReference": [
      {
        "id": "urn:uuid:e6d00349-6d07-4512-9a99-f698d3bc1dba",
        "url": "https://activitypub-testing.socialweb.coop/e6d00349-6d07-4512-9a99-f698d3bc1dba"
      },
      {
        "id": "urn:uuid:104e2cde-f072-43af-badd-bf9bd4129151",
        "url": "https://activitypub-testing.socialweb.coop/104e2cde-f072-43af-badd-bf9bd4129151"
      },
      {
        "id": "urn:uuid:f3725db1-1e6b-4d20-9cea-a49ef4291e9f",
        "url": "https://activitypub-testing.socialweb.coop/f3725db1-1e6b-4d20-9cea-a49ef4291e9f"
      }
    ]
  },
  "input": {
    "outbox": "https://onepage.pub/orderedcollection/VXH9LQd6l8pm015WyWyA7",
    "authorization": {
      "@type": [
        "https://activitypub-testing.socialweb.coop/ns/HiddenInTestResults"
      ]
    }
  },
  "@context": [
    "https://socialweb.coop/ns/testing/context.json",
    "https://www.w3.org/ns/activitystreams"
  ]
}
```
