当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript authorization-check.checkAuthorizationGuards函数代码示例

本文整理汇总了TypeScript中test/features/claimant-response/routes/checks/authorization-check.checkAuthorizationGuards函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkAuthorizationGuards函数的具体用法?TypeScript checkAuthorizationGuards怎么用?TypeScript checkAuthorizationGuards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了checkAuthorizationGuards函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

  describe('on GET', () => {
    const method = 'get'
    checkAuthorizationGuards(app, method, pagePath)
    checkNotClaimantInCaseGuard(app, method, pagePath)

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
      })

      context('when service is unhealthy', () => {
        it('should return 500 and render error page when cannot retrieve claim by external id', async () => {
          claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res).to.be.serverError.withText('Error'))
        })
      })

      context('when claimant has been paid in full', () => {
        it('should display form asking when money was received', async () => {
          claimStoreServiceMock.resolveRetrieveClaimByExternalId()
          draftStoreServiceMock.resolveFind('claim')

          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res).to.be.successful.withText('When did you settle the claim?'))
        })
      })

      context('when claimant has already been paid in full', () => {
        it('should display forbidden page', async () => {
          claimStoreServiceMock.resolveRetrieveClaimByExternalId({ moneyReceivedOn: MomentFactory.currentDate().subtract(1, 'day') })

          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res).to.be.forbidden.withText('Forbidden'))
        })
      })
    })
  })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:45,代码来源:paid-in-full.ts

示例2: describe

  describe('on GET', () => {
    const method = 'get'
    checkAuthorizationGuards(app, method, pagePath)
    checkNotClaimantInCaseGuard(app, method, pagePath)

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
      })

      it('should render page when everything is fine', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
        draftStoreServiceMock.resolveFind('claimantResponse')

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('Repayment plan accepted'))
      })
    })
  })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:21,代码来源:pay-by-set-date-accepted.ts

示例3: describe

  describe('on GET', () => {
    const method = 'get'
    checkAuthorizationGuards(app, method, pagePath)

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
      })

      context('when claimant response submitted', () => {
        it('should return 500 and render error page when cannot retrieve claim', async () => {
          claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res).to.be.serverError.withText('Error'))
        })

        it('should render page when everything is fine', async () => {
          claimStoreServiceMock.resolveRetrieveClaimByExternalId(
            {
              ...claimStoreServiceMock.sampleClaimObj,
              settlement: {
                ...settlementAgreementServiceMock.sampleSettlementAgreementRejection
              }
            })
          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res)
              .to.be.successful.withText('You’ve rejected the settlement agreement'))
        })
      })
    })
  })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:36,代码来源:settlement-agreement-confirmation.ts

示例4: describe

  describe('on GET', () => {
    const method = 'get'
    checkAuthorizationGuards(app, method, pagePath)
    checkNotClaimantInCaseGuard(app, method, pagePath)

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
      })

      context('when response not submitted', () => {
        it('should return 500 and render error page when cannot retrieve claim', async () => {
          claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res).to.be.serverError.withText('Error'))
        })

        it('should render page when everything is fine', async () => {
          claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
          draftStoreServiceMock.resolveFind('claimantResponse', {
            freeMediation: {
              option: FreeMediationOption.NO
            }
          })

          await request(app)
            .get(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .expect(res => expect(res).to.be.successful.withText('Free mediation'))
        })
      })
    })
  })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:36,代码来源:free-mediation.ts

示例5: describe

  describe('on POST', () => {
    const method = 'post'
    checkAuthorizationGuards(app, method, pagePath)
    checkNotClaimantInCaseGuard(app, method, pagePath)

    const validFormData: object = {
      totalAmount: 160,
      instalmentAmount: 30,
      firstPaymentDate: {
        day: 31,
        month: 12,
        year: 2050
      },
      paymentSchedule: 'EVERY_MONTH'
    }

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.submitterId, 'citizen')
      })

      context('when service is unhealthy', () => {
        it('should return 500 and render error page when cannot retrieve claim by external id', async () => {
          claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

          await request(app)
            .post(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .send(validFormData)
            .expect(res => expect(res).to.be.serverError.withText('Error'))
        })

        it('should return 500 and render error page when cannot retrieve draft', async () => {
          claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
          draftStoreServiceMock.rejectFind('Error')

          await request(app)
            .post(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .send(validFormData)
            .expect(res => expect(res).to.be.serverError.withText('Error'))
        })

        it('should return 500 and render error page when cannot save draft', async () => {
          claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
          draftStoreServiceMock.resolveFind('claimantResponse', draftOverride)
          draftStoreServiceMock.rejectSave()

          await request(app)
            .post(pagePath)
            .set('Cookie', `${cookieName}=ABC`)
            .send(validFormData)
            .expect(res => expect(res).to.be.serverError.withText('Error'))
        })
      })

      context('when service is healthy', () => {

        function setFirstPaymentDate (firstPaymentDate: Moment): object {
          return {
            day: firstPaymentDate.date(),
            month: firstPaymentDate.month() + 1,
            year: firstPaymentDate.year()
          }
        }

        function dataToSend (firstPaymentDate: Moment): object {
          return {
            totalAmount: 100,
            instalmentAmount: 50,
            firstPaymentDate: {
              day: firstPaymentDate.date(),
              month: firstPaymentDate.month() + 1,
              year: firstPaymentDate.year()
            },
            paymentSchedule: 'EVERY_MONTH'
          }
        }

        context('when form is valid', async () => {
          beforeEach(() => {
            draftStoreServiceMock.resolveSave()
          })

          it('should redirect to counter offer accepted page when decision type is CLAIMANT', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
            draftStoreServiceMock.resolveFind('claimantResponse', draftOverride)

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send(validFormData)
              .expect(res => expect(res).to.be.redirect.toLocation(Paths.counterOfferAcceptedPage.evaluateUri({ externalId: externalId })))
          })

          it('should redirect to counter offer accepted page when decision type is CLAIMANT_IN_FAVOUR_OF_DEFENDANT', async () => {
            const firstPaymentDate: Moment = MomentFactory.currentDate().add(100, 'years')

            claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimStoreServiceMock.sampleFullAdmissionWithPaymentByInstalmentsResponseObj)
            draftStoreServiceMock.resolveFind('claimantResponse', draftOverride)
//.........这里部分代码省略.........
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:101,代码来源:payment-plan.ts

示例6: describe

    describe('on POST', () => {
      const method = 'post'
      checkAuthorizationGuards(app, method, pagePath)
      checkNotClaimantInCaseGuard(app, method, pagePath)

      context('when user authorised', () => {
        beforeEach(() => {
          idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
        })

        context('when middleware failure', () => {
          it('should return 500 when cannot retrieve claim by external id', async () => {
            claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send(validFormData)
              .expect(res => expect(res).to.be.serverError.withText('Error'))
          })

          it('should return 500 when cannot retrieve claimantResponse draft', async () => {
            draftStoreServiceMock.rejectFind('Error')
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send(validFormData)
              .expect(res => expect(res).to.be.serverError.withText('Error'))
          })
        })

        context('when form is valid', async () => {
          it('should redirect to task list page', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
            draftStoreServiceMock.resolveFind('claimantResponse')
            draftStoreServiceMock.resolveSave()

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send(validFormData)
              .expect(res => expect(res).to.be.redirect.toLocation(taskListPagePath))
          })

          it('should return 500 and render error page when cannot save claimantResponse draft', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
            draftStoreServiceMock.resolveFind('claimantResponse')
            draftStoreServiceMock.rejectSave()

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send(validFormData)
              .expect(res => expect(res).to.be.serverError.withText('Error'))
          })
        })

        context('when form is invalid', async () => {
          it('should render page', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
            draftStoreServiceMock.resolveFind('claimantResponse')

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send({ option: undefined })
              .expect(res => expect(res).to.be.successful.withText('Do you want to settle the claim', 'div class="error-summary"'))
          })
        })

      })
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:74,代码来源:settle-admitted.ts

示例7: describe

  describe('on GET', () => {
    const method = 'get'
    checkAuthorizationGuards(app, method, pagePath)
    checkNotClaimantInCaseGuard(app, method, pagePath)

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor('1', 'citizen')
      })

      it('should return 500 and render error page when cannot retrieve claims', async () => {
        claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.serverError.withText('Error'))
      })

      it('should return 500 and render error page when cannot retrieve claimantResponse draft', async () => {
        draftStoreServiceMock.rejectFind('Error')
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.serverError.withText('Error'))
      })

      it('should render page when everything is fine', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
        draftStoreServiceMock.resolveFind('claimantResponse', {
          courtDetermination: {
            decisionType: 'DEFENDANT',
            courtDecision: {
              paymentOption: 'BY_SPECIFIED_DATE',
              paymentDate: MomentFactory.parse('2018-11-01'),
              repaymentPlan: undefined }
          }
        })

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('The defendant can’t pay by your proposed date'))
      })

      it('should render page when everything is fine and COURT date is accepted', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantPartialAdmissionResponse)
        draftStoreServiceMock.resolveFind('claimantResponse', {
          courtDetermination: {
            decisionType: 'COURT',
            courtDecision: {
              paymentOption: 'BY_SPECIFIED_DATE',
              paymentDate: MomentFactory.parse('2018-11-01'),
              repaymentPlan: undefined }
          }
        })

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('The defendant can’t pay by your proposed date'))
      })

      it('should render page when everything is fine and CLAIMANT date is accepted', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(defendantFullAdmissionResponse)
        draftStoreServiceMock.resolveFind('claimantResponse', {
          courtDetermination: {
            decisionType: 'CLAIMANT',
            courtDecision: {
              paymentOption: 'BY_SPECIFIED_DATE',
              paymentDate: MomentFactory.parse('2018-11-01'),
              repaymentPlan: undefined }
          },
          alternatePaymentMethod: {
            paymentOption: {
              option: {
                value: 'BY_SPECIFIED_DATE',
                displayValue: 'By set date'
              }
            },
            paymentDate: new PaymentDate(new LocalDate(2018,11,1)),
            paymentPlan: undefined
          }
        })

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('The defendant can’t pay by your proposed date'))
      })
    })

  })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:95,代码来源:court-offered-set-date.ts

示例8: describe

  describe('on POST', () => {
    const method = 'post'
    checkAuthorizationGuards(app, method, pagePath)

    context('when user authorised', () => {
      beforeEach(() => {
        idamServiceMock.resolveRetrieveUserFor(claimStoreServiceMock.sampleClaimObj.defendantId, 'citizen')
      })

      context('when response not submitted', () => {
        context('when form is invalid', () => {
          it('should return 500 and render error page when cannot retrieve claim', async () => {
            claimStoreServiceMock.rejectRetrieveClaimByExternalId('HTTP error')

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .expect(res => expect(res).to.be.serverError.withText('Error'))
          })

          it('should render page when everything is fine', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .expect(res => expect(res).to.be.successful.withText('Respond to the settlement agreement', 'div class="error-summary"'))
          })
        })

        context('when form is valid', () => {

          it('should return 500 and render error page when cannot post to claim store', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
            settlementAgreementServiceMock.rejectRejectSettlementAgreement()

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send({ option: 'no' })
              .expect(res => expect(res).to.be.serverError.withText('Error'))
          })

          it('should redirect to confirmation page when everything is fine and settlement agreement is rejected', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
            settlementAgreementServiceMock.resolveRejectSettlementAgreement()

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send({ option: 'no' })
              .expect(res => expect(res).to.be.redirect
                .toLocation(Paths.settlementAgreementConfirmation
                  .evaluateUri({ externalId: externalId })))
          })

          it('should redirect to confirmation page when everything is fine and settlement agreement is accepted', async () => {
            claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
            settlementAgreementServiceMock.resolveCountersignSettlementAgreement()

            await request(app)
              .post(pagePath)
              .set('Cookie', `${cookieName}=ABC`)
              .send({ option: 'yes' })
              .expect(res => expect(res).to.be.redirect
                .toLocation(Paths.settlementAgreementConfirmation
                  .evaluateUri({ externalId: externalId })))
          })
        })
      })
    })
  })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:72,代码来源:sign-settlement-agreement.ts


注:本文中的test/features/claimant-response/routes/checks/authorization-check.checkAuthorizationGuards函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。