コード例 #1
0
ファイル: checkr_test.go プロジェクト: outdoorsy/checkr
func TestCheckrReports(t *testing.T) {
	is := is.New(t)

	c := createCandidate(is)

	r, err := Reports.Create(c.ID, "driver_pro")
	is.NotErr(err)

	is.NotZero(r.ID)
	is.NotZero(r.Object)
	is.NotZero(r.URI)
	is.NotZero(r.SSNTraceID)
	is.NotZero(r.MotorVehicleReportID)
}
コード例 #2
0
ファイル: onfido_test.go プロジェクト: outdoorsy/onfido
func TestClientChecks(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping test in short mode.")
	}

	is := is.New(t)
	checkToken(is)

	c := New(*token)
	is.NotNil(c)

	nowDate = Date(time.Now().Add(-5 * time.Hour * 24))

	nameNum := rand.Int31()

	a := &Applicant{
		Country:   "USA",
		FirstName: "Tyler" + strconv.Itoa(int(nameNum)),
		LastName:  "Bunnell" + strconv.Itoa(int(nameNum)),
		Email:     "tyler" + strconv.Itoa(int(nameNum)) + "@fake.com",
		Gender:    "male",
		Dob:       &nowDate,
		IDNumbers: testIDNumbers,
		Telephone: "555-738-6874",
		Addresses: testAddress,
	}

	a, err := c.CreateApplicant(a)
	is.NotErr(err)
	is.NotZero(a.ID)
	is.NotZero(a.Href)

	ch, err := c.CreateCheck(a.ID,
		NewCheckRequest(CheckType.Express,
			ReportType.USA.Identity, ReportType.USA.DrivingRecord))
	is.NotErr(err)
	is.NotNil(ch)
	is.NotZero(ch.ID)
	is.NotZero(ch.CreatedAt)
	is.Equal(ch.Type, "express")
	is.Equal(ch.Result, "consider")
	is.NotZero(ch.Href)
	is.NotNil(ch.Reports)
	is.Equal(len(ch.Reports), 2)

	ch, err = c.ReadCheck(a.ID, ch.ID)
	is.NotErr(err)
	is.NotNil(ch)
	is.NotZero(ch.ID)
	is.NotZero(ch.CreatedAt)
	is.Equal(ch.Type, "express")
	is.Equal(ch.Result, "consider")
	is.NotZero(ch.Href)
	is.NotNil(ch.Reports)
	is.Equal(len(ch.Reports), 2)

	chs, err := c.ReadChecks(a.ID)
	is.NotErr(err)
	is.NotEqual(len(chs), 0)
}
コード例 #3
0
ファイル: onfido_test.go プロジェクト: outdoorsy/onfido
func TestClientApplicants(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping test in short mode.")
	}

	is := is.New(t)
	checkToken(is)

	c := New(*token)
	is.NotNil(c)

	nameNum := rand.Int31()

	nowDate = Date(time.Now().Add(-5 * time.Hour * 24))

	a := &Applicant{
		Country:   "USA",
		FirstName: "Tyler" + strconv.Itoa(int(nameNum)),
		LastName:  "Bunnell" + strconv.Itoa(int(nameNum)),
		Email:     "tyler" + strconv.Itoa(int(nameNum)) + "@fake.com",
		Gender:    "male",
		Dob:       &nowDate,
		IDNumbers: testIDNumbers,
		Telephone: "555-738-6874",
		Addresses: testAddress,
	}

	a, err := c.CreateApplicant(a)
	is.NotErr(err)
	is.NotZero(a.ID)
	is.NotZero(a.Href)

	a, err = c.ReadApplicant(a.ID)
	is.NotErr(err)
	is.NotZero(a.ID)
	is.NotZero(a.Href)

	apps, err := c.ReadApplicants()
	is.NotErr(err)
	is.NotEqual(len(apps), 0)
}
コード例 #4
0
ファイル: webhook_test.go プロジェクト: outdoorsy/checkr
func TestWebhook(t *testing.T) {
	is := is.New(t)

	inString := `{
  "id": "507f1f77bcf86cd799439011",
  "object": "event",
  "type": "report.completed",
  "created_at": "2014-01-18T12:34:00Z",
  "webhook_url": "https://yourcompany.com/checkr/incoming",
  "data": {
    "object": {
      "id": "4722c07dd9a10c3985ae432a",
      "object": "report",
      "uri": "/v1/reports/532e71cfe88a1d4e8d00000d",
      "created_at": "2014-01-18T12:34:00Z",
      "received_at": "2014-01-18T12:34:00Z",
      "status": "clear",
      "package": "driver_pro",
      "candidate_id": "e44aa283528e6fde7d542194",
      "ssn_trace_id": "539fd88c101897f7cd000001",
      "sex_offender_search_id": "539fd88c101897f7cd000008",
      "national_criminal_search_id": "539fd88c101897f7cd000006",
      "county_criminal_search_ids": [
        "539fdcf335644a0ef4000001",
        "532e71cfe88a1d4e8d00000i"
      ],
      "motor_vehicle_report_id": "539fd88c101897f7cd000007"
    }
  }
}`

	r, err := http.NewRequest("POST", "https://webhook.com", strings.NewReader(inString))
	is.NotErr(err)

	mac := hmac.New(sha256.New, []byte(Key))
	mac.Write([]byte(inString))
	sig := hex.EncodeToString(mac.Sum(nil))

	r.Header.Set(webhookSignatureKey, sig)

	w, err := NewWebhook(r)
	is.NotErr(err)
	is.True(w.IsReport())
	is.False((w.IsCandidate()))

	rep := w.Report()
	is.NotNil(rep)
	is.Equal(w.Type, WebhookType.Report.Completed)
	is.NotZero(rep.MotorVehicleReportID)
}
コード例 #5
0
ファイル: event_test.go プロジェクト: outdoorsy/onfido
func TestEventUnmarshalEvent(t *testing.T) {
	is := is.New(t)

	body := []byte(`{"payload":{"resource_type":"report","action":"completed","object":{"id":"50e65977-496f-464a-be73-836def7bea6c","status":"completed","completed_at":"2006-01-02 15:04:05 MST","href":"https://api.onfido.com/checks/dd29776f-26fa-452f-90f1-9c8ce4fcec3e/reports/50e65977-496f-464a-be73-836def7bea6c"}}}`)

	c := New("none")
	c.WebhookToken = "kCxrT1iqSqlxf1OeQi2On5M-1fA6xnr3"

	r, err := http.NewRequest("POST", "/webhook", bytes.NewReader(body))
	is.NotErr(err)
	r.Header.Set("X-Signature", "8fe7130c7e193b5049daafb507ad246047c69bc4")

	event, err := c.UnmarshalEvent(r)
	is.NotErr(err)
	is.Equal(event.Payload.ResourceType, "report")
	is.Equal(event.Payload.Action, "completed")
	is.NotZero(event.Payload.Object.ID)
	is.Equal(event.Payload.Object.Status, "completed")
	tc, err := time.Parse(eventTimeFormat, "2006-01-02 15:04:05 MST")
	is.NotErr(err)
	is.Equal(event.Payload.Object.CompletedAt, tc)
	is.Equal(event.Payload.Object.Href, "https://api.onfido.com/checks/dd29776f-26fa-452f-90f1-9c8ce4fcec3e/reports/50e65977-496f-464a-be73-836def7bea6c")
}