Add visitor phone lookup flow
This commit is contained in:
@@ -2,10 +2,12 @@ package httpapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"calllinesystem/server/internal/config"
|
||||
"calllinesystem/server/internal/model"
|
||||
)
|
||||
|
||||
@@ -28,3 +30,27 @@ func TestDisplayBatchDTOCannotSerializePersonalFields(t *testing.T) {
|
||||
t.Fatalf("public ticket number missing: %s", encoded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicPhoneLookupIsDisabledInProduction(t *testing.T) {
|
||||
server := &Server{config: config.Config{Environment: "production"}}
|
||||
recorder := httptest.NewRecorder()
|
||||
request := httptest.NewRequest("POST", "/api/public/status/search", strings.NewReader(`{"phone":"13800138000"}`))
|
||||
|
||||
server.publicStatusByPhone(recorder, request)
|
||||
|
||||
if recorder.Code != 404 {
|
||||
t.Fatalf("production phone lookup status = %d, want 404", recorder.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicPhoneLookupRejectsInvalidPhone(t *testing.T) {
|
||||
server := &Server{config: config.Config{Environment: "development"}}
|
||||
recorder := httptest.NewRecorder()
|
||||
request := httptest.NewRequest("POST", "/api/public/status/search", strings.NewReader(`{"phone":"123"}`))
|
||||
|
||||
server.publicStatusByPhone(recorder, request)
|
||||
|
||||
if recorder.Code != 422 {
|
||||
t.Fatalf("invalid phone lookup status = %d, want 422", recorder.Code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user