auth-ui: rewrite ui

Change-Id: I6f00867015ec77aa7e336e89da4dc1b081e330c6
diff --git a/core/auth/ui/api_test.go b/core/auth/ui/api_test.go
index 90e64be..1f653dd 100644
--- a/core/auth/ui/api_test.go
+++ b/core/auth/ui/api_test.go
@@ -1,19 +1,27 @@
 package main
 
 import (
+	"net/http"
+	"net/http/httptest"
+	"strings"
 	"testing"
 )
 
-func TestPasswordInvalid(t *testing.T) {
-	errs := validatePassword("foobar")
-	if len(errs) != 2 {
-		t.Fatal(errs)
-	}
-}
+func TestIdentityCreateSharedValidationResponseRemainsCompatible(t *testing.T) {
+	server := NewAPIServer(0, "http://kratos.invalid")
+	request := httptest.NewRequest(http.MethodPost, "/identities", strings.NewReader(`{"username":"x","password":"short"}`))
+	recorder := httptest.NewRecorder()
+	server.identityCreate(recorder, request)
 
-func TestPasswordValid(t *testing.T) {
-	errs := validatePassword("foBa2r-gdkjS1-SA0120")
-	if len(errs) != 0 {
-		t.Fatal(errs)
+	const expected = `{"errors":[{"field":"username","message":"Username must be at least 3 characters long."},{"field":"password","message":"Password must be at least 20 characters long."},{"field":"password","message":"Password must contain at least one digit, lower\u0026upper case and special characters"}]}
+`
+	if recorder.Code != http.StatusBadRequest {
+		t.Fatalf("status = %d, want 400", recorder.Code)
+	}
+	if got := recorder.Header().Get("Content-Type"); got != "application/json" {
+		t.Fatalf("content type = %q", got)
+	}
+	if got := recorder.Body.String(); got != expected {
+		t.Fatalf("body = %q, want byte-compatible %q", got, expected)
 	}
 }