當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript authorization-check.checkAuthorizationGuards函數代碼示例

本文整理匯總了TypeScript中test/routes/authorization-check.checkAuthorizationGuards函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript checkAuthorizationGuards函數的具體用法?TypeScript checkAuthorizationGuards怎麽用?TypeScript checkAuthorizationGuards使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了checkAuthorizationGuards函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

  describe('delete a date', () => {
    const deletePath = Paths.hearingDatesDeleteReceiver.evaluateUri({ externalId: externalId, index: 'date-1' })

    const method = 'get'
    checkAuthorizationGuards(app, method, deletePath)
    checkAccessGuard(app, method, deletePath)

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

      it('should redirect to the hearing dates page', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(claim)
        draftStoreServiceMock.resolveFind('directionsQuestionnaire', {
          availability: {
            hasUnavailableDates: true,
            unavailableDates: unavailableDates
          }
        })
        draftStoreServiceMock.resolveFind('response')
        draftStoreServiceMock.resolveSave()

        await request(app)
          .get(deletePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.redirect.toLocation(hearingDatesPath))
      })
    })
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:30,代碼來源:hearing-dates-picker.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 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 render page when everything is fine', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId()
        draftStoreServiceMock.resolveFind('paidInFull')

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('When did you settle the claim?'))
      })
    })
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:30,代碼來源:date-paid.ts

示例3: describe

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

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

      checkAlreadySubmittedGuard(app, method, pagePath)
      checkCountyCourtJudgmentRequestedGuard(app, method, pagePath)
      checkErrorHandling(method)

      it('should render page when everything is fine', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId()
        draftStoreServiceMock.resolveFind('response:full-admission')

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('Debts you’re behind on'))
      })
    })
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:25,代碼來源:priority-debt.ts

示例4: describe

  describe('on GET', () => {
    checkAuthorizationGuards(app, 'get', incompleteSubmissionPagePath)

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

      await request(app)
        .get(taskListPagePath)
        .set('Cookie', `${cookieName}=ABC`)
        .expect(res => expect(res).to.be.successful.withText('Your response'))
    })
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:15,代碼來源:task-list.ts

示例5: describe

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

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

      it('should render page when everything is fine', async () => {
        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText(pageText))
      })
    })
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:16,代碼來源:create-claim-draft.ts

示例6: describe

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

    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 directions questionnaire draft', async () => {
        claimStoreServiceMock.resolveRetrieveClaimByExternalId(claimWithDQ)
        draftStoreServiceMock.rejectFind('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(claimWithDQ)
        draftStoreServiceMock.resolveFind('directionsQuestionnaire')
        draftStoreServiceMock.resolveFind('response')

        await request(app)
          .get(pagePath)
          .set('Cookie', `${cookieName}=ABC`)
          .expect(res => expect(res).to.be.successful.withText('Does the claim involve something an expert can still examine?'))
      })
    })
  })
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:41,代碼來源:expert-evidence.ts

示例7: checkAuthorizationGuards

export function checkAuthorizationGuards (app: any, method: string, pagePath: string) {
  check(app, method, pagePath)
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:authorization-check.ts


注:本文中的test/routes/authorization-check.checkAuthorizationGuards函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。