本文整理汇总了TypeScript中test/features/claim/routes/checks/authorization-check.checkAuthorizationGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkAuthorizationGuards函数的具体用法?TypeScript checkAuthorizationGuards怎么用?TypeScript checkAuthorizationGuards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkAuthorizationGuards函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when user role not present and everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveUserRoles()
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Try new features'))
})
it('should not render page when new feature consent role present', async () => {
claimStoreServiceMock.resolveRetrieveUserRoles('cmc-new-features-consent-given')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
it('should return 500 when role cannot be retrieved', async () => {
claimStoreServiceMock.rejectRetrieveUserRoles()
await request(app)
.get(ClaimPaths.newFeaturesConsentPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('error'))
})
})
})
示例2: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.resolvingThisDisputerPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.resolvingThisDisputerPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.resolvingThisDisputerPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list when everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.resolvingThisDisputerPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
})
})
示例3: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', ClaimPaths.confirmationPage.evaluateUri({ externalId: externalId }))
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot retrieve claim by external id', async () => {
claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')
await request(app)
.get(ClaimPaths.confirmationPage.evaluateUri({ externalId: externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should render page when everything is fine', async () => {
claimStoreServiceMock.resolveRetrieveClaimByExternalId()
await request(app)
.get(ClaimPaths.confirmationPage.evaluateUri({ externalId: externalId }))
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Claim submitted'))
})
})
})
示例4: describe
describe('on POST', () => {
const method = 'post'
checkAuthorizationGuards(app, method, pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should return 500 and render error page when cannot retrieve draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('valid form should redirect to task list', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave(100)
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ rows: [{ type: EvidenceType.CONTRACTS_AND_AGREEMENTS.value, description: 'Bla bla' }] })
.expect(res => expect(res).to.be.redirect.toLocation(Paths.taskListPage.uri))
})
it('should render page when missing description', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({
rows: [{
type: EvidenceType.CONTRACTS_AND_AGREEMENTS.value,
description: undefined
}]
})
.expect(res => expect(res).to.be.redirect.toLocation(Paths.taskListPage.uri))
})
describe('add row action', () => {
it('should render page when valid input', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ action: { addRow: 'Add row' } })
.expect(res => expect(res).to.be.successful.withText('List any evidence (optional)'))
})
})
})
})
示例5: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', pagePath)
checkEligibilityGuards(app, 'post', pagePath)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(pageContent, 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: InterestDateType.SUBMISSION })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to total page when form is valid, submission date selected and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({ type: InterestDateType.SUBMISSION })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.totalPage.uri))
})
it('should redirect to interest start date page when form is valid, custom date selected and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.send({
type: InterestDateType.CUSTOM
})
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.interestStartDatePage.uri))
})
})
})
示例6: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.checkAndSendPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.checkAndSendPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should redirect to incomplete submission when not all tasks are completed', async () => {
draftStoreServiceMock.resolveFind('claim', { readResolveDispute: false })
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.incompleteSubmissionPage.uri))
})
it('should return 500 and render error page when form is invalid and cannot calculate fee', async () => {
draftStoreServiceMock.resolveFind('claim')
feesServiceMock.rejectCalculateIssueFee('HTTP error')
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
feesServiceMock.resolveCalculateIssueFee()
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('Check your answers', 'div class="error-summary"'))
})
it('should redirect to payment page when form is valid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.checkAndSendPage.uri)
.send({ type: SignatureType.BASIC })
.set('Cookie', `${cookieName}=ABC`)
.send({ signed: 'true' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.startPaymentReceiver.uri))
})
})
})
示例7: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.defendantEmailPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.defendantEmailPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: 'invalid-email-address' })
.expect(res => expect(res).to.be.successful.withText('Their email address (optional)', 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: 'defendant@example.com' })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list when form is valid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: 'defendant@example.com' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
it('should redirect to task list when no email address is given', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.defendantEmailPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ address: '' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
})
})
示例8: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.claimantMobilePage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.claimantMobilePage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is invalid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(headerText, 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '07000000000' })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to task list when form is valid and nothing is submitted', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
it('should redirect to task list when form is valid and number is provided', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.claimantMobilePage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ number: '07000000000' })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.taskListPage.uri))
})
})
})
示例9: describe
describe('on GET', () => {
checkAuthorizationGuards(app, 'get', pagePath)
it('should render page when everything is fine', async () => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
draftStoreServiceMock.resolveFind('claim')
await request(app)
.get(pagePath)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText(pageContent))
})
})
示例10: describe
describe('on POST', () => {
checkAuthorizationGuards(app, 'post', ClaimPaths.claimantDateOfBirthPage.uri)
checkEligibilityGuards(app, 'post', ClaimPaths.claimantDateOfBirthPage.uri)
describe('for authorized user', () => {
beforeEach(() => {
idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
})
it('should render page when form is empty and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.expect(res => expect(res).to.be.successful.withText('What is your date of birth?', 'div class="error-summary"'))
})
it('should render page with error when DOB is less than 18', async () => {
draftStoreServiceMock.resolveFind('claim')
const date: Moment = MomentFactory.currentDate().subtract(1, 'year')
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: 'true', date: { day: date.date(), month: date.month() + 1, year: date.year() } })
.expect(res => expect(res).to.be.successful.withText('Please enter a date of birth before', 'div class="error-summary"'))
})
it('should return 500 and render error page when form is valid and cannot save draft', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.rejectSave()
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: 'true', date: { day: '31', month: '12', year: '1980' } })
.expect(res => expect(res).to.be.serverError.withText('Error'))
})
it('should redirect to claimant mobile page when form is valid and everything is fine', async () => {
draftStoreServiceMock.resolveFind('claim')
draftStoreServiceMock.resolveSave()
await request(app)
.post(ClaimPaths.claimantDateOfBirthPage.uri)
.set('Cookie', `${cookieName}=ABC`)
.send({ known: 'true', date: { day: '31', month: '12', year: '1980' } })
.expect(res => expect(res).to.be.redirect.toLocation(ClaimPaths.claimantMobilePage.uri))
})
})
})