-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from hyphacoop/trial-publisher
Add trial publisher API
- Loading branch information
Showing
5 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,3 +161,38 @@ test('E2E: admin -> publisher -> site flow', async t => { | |
}) | ||
t.is(deleteSiteResponse.statusCode, 200, 'deleting site returns a status code of 200') | ||
}) | ||
|
||
test('Create trial publisher', async t => { | ||
// create an admin | ||
const trialResponse = await t.context.server.inject({ | ||
method: 'POST', | ||
url: '/v1/publisher/trial', | ||
payload: { | ||
name: '[email protected]' | ||
} | ||
}) | ||
t.is(trialResponse.statusCode, 200, 'creating trial returns OK') | ||
const token = trialResponse.body | ||
|
||
// use access token to create a new site | ||
const createSiteResponse = await t.context.server.inject({ | ||
method: 'POST', | ||
url: '/v1/sites', | ||
headers: { | ||
authorization: `Bearer ${token}` | ||
}, | ||
payload: exampleSiteConfig | ||
}) | ||
t.is(createSiteResponse.statusCode, 200, 'creating a site works with trial token') | ||
|
||
// use access token to create a new site | ||
const createSiteResponse2 = await t.context.server.inject({ | ||
method: 'POST', | ||
url: '/v1/sites', | ||
headers: { | ||
authorization: `Bearer ${token}` | ||
}, | ||
payload: { ...exampleSiteConfig, domain: 'example2' } | ||
}) | ||
t.is(createSiteResponse2.statusCode, 402, 'Error when creating second site') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters