Test Overview
This test verifies that a Postman collection can be shared successfully with a team member and that the shared collection is accessible to them.
This test verifies that a Postman collection can be shared successfully with a team member and that the shared collection is accessible to them.
pm.test("Share collection with team member", async function () { // Step 1: Authenticate as collection owner const ownerToken = pm.environment.get("owner_token"); // Step 2: Share collection via API const collectionId = pm.environment.get("collection_id"); const shareWithUserId = pm.environment.get("team_member_id"); const shareResponse = await pm.sendRequest({ url: `https://api.getpostman.com/collections/${collectionId}/share`, method: 'POST', header: { 'X-Api-Key': ownerToken, 'Content-Type': 'application/json' }, body: { mode: 'raw', raw: JSON.stringify({ userId: shareWithUserId, permission: 'edit' }) } }); pm.expect(shareResponse.code).to.eql(200); // Step 3: Authenticate as team member and verify access const memberToken = pm.environment.get("team_member_token"); const accessResponse = await pm.sendRequest({ url: `https://api.getpostman.com/collections/${collectionId}`, method: 'GET', header: { 'X-Api-Key': memberToken } }); pm.expect(accessResponse.code).to.eql(200); pm.expect(accessResponse.json().collection.id).to.eql(collectionId); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Authenticate as collection owner using API key from environment | Owner token is loaded from environment variables | - | PASS |
| 2 | Send POST request to share collection with team member using owner token | API receives share request with userId and permission | Response code is 200 indicating successful share | PASS |
| 3 | Authenticate as team member using their API key | Team member token is loaded from environment variables | - | PASS |
| 4 | Send GET request to retrieve shared collection using team member token | API returns collection details to team member | Response code is 200 and collection id matches shared collection | PASS |