コード例 #1
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)
}
コード例 #2
0
ファイル: gls_test.go プロジェクト: robmurtha/gls
func TestGLSSetValues(t *testing.T) {
	is := is.New(t)

	Set("key", "value")
	v := Get("key")
	is.NotNil(v)
	is.Equal(v, "value")

	SetValues(Values{"answer": 42})
	v = Get("key")
	is.Nil(v)

	v = Get("answer")
	is.NotNil(v)
	is.Equal(v, 42)

	Cleanup()
}
コード例 #3
0
ファイル: gls_test.go プロジェクト: robmurtha/gls
func TestGLS(t *testing.T) {
	is := is.New(t)

	Set("key", "value")
	v := Get("key")
	is.NotNil(v)
	is.Equal(v, "value")

	Cleanup()
}
コード例 #4
0
ファイル: gls_test.go プロジェクト: robmurtha/gls
func TestGLSWith(t *testing.T) {
	is := is.New(t)

	With(Values{"key": "value"}, func() {
		v := Get("key")
		is.NotNil(v)
		is.Equal(v, "value")
	})

	v := Get("key")
	is.Nil(v)
}
コード例 #5
0
ファイル: gls_test.go プロジェクト: robmurtha/gls
func TestGLSGo(t *testing.T) {
	is := is.New(t)

	var wg sync.WaitGroup
	wg.Add(3)

	Set("key", "value")

	Go(func() {
		v := Get("key")
		is.NotNil(v)
		is.Equal(v, "value")
		Go(func() {
			v := Get("key")
			is.NotNil(v)
			is.Equal(v, "value")
			Set("answer", 42)
			Go(func() {
				v := Get("key")
				is.NotNil(v)
				is.Equal(v, "value")
				v = Get("answer")
				is.NotNil(v)
				is.Equal(v, 42)
				wg.Done()
			})
			wg.Done()
		})
		wg.Done()
	})

	v := Get("key")
	is.NotNil(v)
	is.Equal(v, "value")

	wg.Wait()

	Cleanup()
}
コード例 #6
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)
}
コード例 #7
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)
}