registrar/openprovider: /v1 adapter (check, contact, register, lookup, balance)
Co-Authored-By: Astra (gpt-6-astra) via Codex <noreply@openai.com>
13 files changed,
+1,928
−0
internal/registrar/openprovider/client.go+494 −0internal/registrar/openprovider/client_test.go+546 −0internal/registrar/openprovider/testdata/README.md+20 −0internal/registrar/openprovider/testdata/balance.json+399 −0internal/registrar/openprovider/testdata/check-reference.json+32 −0internal/registrar/openprovider/testdata/check.json+32 −0internal/registrar/openprovider/testdata/contact-create.json+7 −0internal/registrar/openprovider/testdata/contact-get.json+124 −0internal/registrar/openprovider/testdata/contact-update.json+7 −0internal/registrar/openprovider/testdata/login.json+8 −0internal/registrar/openprovider/testdata/lookup.json+192 −0internal/registrar/openprovider/testdata/register.json+62 −0internal/registrar/openprovider/testdata/taken.json+5 −0
diff --git a/internal/registrar/openprovider/client.go b/internal/registrar/openprovider/client.go| new file mode 100644 |
| index 000000000..bb9ae6e2d |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/client.go |
| @@ -0,0 +1,494 @@ |
| +package openprovider |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "math/big" |
| + "net/http" |
| + "net/url" |
| + "strconv" |
| + "strings" |
| + "sync" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registrar" |
| + "golang.org/x/text/currency" |
| +) |
| + |
| +type Config struct { |
| + BaseURL, Username, Password string |
| + HTTP *http.Client |
| +} |
| + |
| +type Client struct { |
| + baseURL, endpoint, username, password string |
| + http *http.Client |
| + mu sync.Mutex |
| + token string |
| +} |
| + |
| +var _ registrar.Registrar = (*Client)(nil) |
| + |
| +func New(cfg Config) (*Client, error) { |
| + for _, f := range []struct{ name, value string }{{"BaseURL", cfg.BaseURL}, {"Username", cfg.Username}, {"Password", cfg.Password}} { |
| + if strings.TrimSpace(f.value) == "" { |
| + return nil, fmt.Errorf("openprovider: %s is required", f.name) |
| + } |
| + } |
| + u, err := url.Parse(cfg.BaseURL) |
| + if err != nil || u.Host == "" || (u.Scheme != "http" && u.Scheme != "https") || u.User != nil || u.RawQuery != "" || u.Fragment != "" { |
| + return nil, errors.New("openprovider: invalid BaseURL") |
| + } |
| + endpoint := strings.TrimRight(cfg.BaseURL, "/") |
| + if !strings.HasSuffix(endpoint, "/v1") { |
| + endpoint += "/v1" |
| + } |
| + hc := http.Client{Timeout: 30 * time.Second} |
| + if cfg.HTTP != nil { |
| + hc = *cfg.HTTP |
| + } |
| + // A redirect could resend a purchase or send credentials to another endpoint. |
| + hc.CheckRedirect = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse } |
| + return &Client{baseURL: cfg.BaseURL, endpoint: endpoint, username: cfg.Username, password: cfg.Password, http: &hc}, nil |
| +} |
| + |
| +func (c *Client) String() string { return "openprovider(" + c.baseURL + ")" } |
| +func (c *Client) GoString() string { return c.String() } |
| + |
| +type domainName struct { |
| + Name string `json:"name"` |
| + Extension string `json:"extension"` |
| +} |
| + |
| +func splitDomain(domain string) (domainName, error) { |
| + name, extension, ok := strings.Cut(domain, ".") |
| + if !ok || name == "" || extension == "" || strings.ContainsAny(domain, " /?#\t\r\n") { |
| + return domainName{}, fmt.Errorf("%w: invalid domain", registrar.ErrRefused) |
| + } |
| + return domainName{Name: name, Extension: extension}, nil |
| +} |
| + |
| +func (c *Client) Check(ctx context.Context, domain string) (registrar.Availability, error) { |
| + result := registrar.Availability{Domain: domain} |
| + d, err := splitDomain(domain) |
| + if err != nil { |
| + return result, err |
| + } |
| + request := struct { |
| + Domains []domainName `json:"domains"` |
| + WithPrice bool `json:"with_price"` |
| + }{[]domainName{d}, true} |
| + var response struct { |
| + Results []struct { |
| + Domain string `json:"domain"` |
| + Status string `json:"status"` |
| + Premium bool `json:"is_premium"` |
| + Price struct { |
| + Reseller struct { |
| + Currency string `json:"currency"` |
| + Price json.Number `json:"price"` |
| + } `json:"reseller"` |
| + } `json:"price"` |
| + } `json:"results"` |
| + } |
| + if err := c.call(ctx, http.MethodPost, "/domains/check", request, &response); err != nil { |
| + return result, err |
| + } |
| + if len(response.Results) != 1 || response.Results[0].Domain != domain || response.Results[0].Status == "" { |
| + return result, errors.New("openprovider: invalid availability response") |
| + } |
| + r := response.Results[0] |
| + result.Available, result.Premium = r.Status == "free", r.Premium |
| + // Unavailable names can lack prices. An available name must have a usable cost. |
| + if !result.Available && r.Price.Reseller.Price == "" { |
| + return result, nil |
| + } |
| + result.Cost, err = money(r.Price.Reseller.Currency, r.Price.Reseller.Price) |
| + return result, err |
| +} |
| + |
| +type contactName struct { |
| + First string `json:"first_name"` |
| + Last string `json:"last_name"` |
| +} |
| + |
| +type contactFields struct { |
| + Email string `json:"email"` |
| + Address struct { |
| + Street string `json:"street"` |
| + Number string `json:"number,omitempty"` |
| + City string `json:"city"` |
| + State string `json:"state,omitempty"` |
| + Zipcode string `json:"zipcode"` |
| + Country string `json:"country"` |
| + } `json:"address"` |
| + Phone struct { |
| + CountryCode string `json:"country_code"` |
| + AreaCode string `json:"area_code"` |
| + Subscriber string `json:"subscriber_number"` |
| + } `json:"phone"` |
| +} |
| + |
| +func (c *Client) EnsureContact(ctx context.Context, handle string, in registrar.Contact) (string, error) { |
| + if err := in.Validate(); err != nil { |
| + return "", fmt.Errorf("%w: %v", registrar.ErrRefused, err) |
| + } |
| + identity := contactName{First: in.FirstName, Last: in.LastName} |
| + if handle != "" { |
| + var previous struct { |
| + Name *contactName `json:"name"` |
| + Company string `json:"company_name"` |
| + } |
| + if err := c.call(ctx, http.MethodGet, "/customers/"+url.PathEscape(handle), nil, &previous); err != nil { |
| + return "", err |
| + } |
| + if previous.Name == nil || previous.Name.First == "" || previous.Name.Last == "" { |
| + return "", errors.New("openprovider: missing customer identity") |
| + } |
| + if *previous.Name != identity || previous.Company != in.Company { |
| + handle = "" |
| + } |
| + } |
| + var fields contactFields |
| + fields.Email = in.Email |
| + fields.Address.Street, fields.Address.Number = streetNumber(in.Street, in.HouseNumber) |
| + fields.Address.City, fields.Address.State, fields.Address.Zipcode, fields.Address.Country = in.City, in.State, in.PostalCode, in.Country |
| + // The split preserves the national number. Short numbers go to the provider |
| + // with an empty area code so its validation can refuse them before payment. |
| + split := max(0, min(3, len(in.Phone)-4)) |
| + fields.Phone.CountryCode = "+" + in.PhoneCountryCode |
| + fields.Phone.AreaCode, fields.Phone.Subscriber = in.Phone[:split], in.Phone[split:] |
| + if handle != "" { |
| + var response struct { |
| + Success bool `json:"success"` |
| + } |
| + if err := c.call(ctx, http.MethodPut, "/customers/"+url.PathEscape(handle), fields, &response); err != nil { |
| + return "", err |
| + } |
| + if !response.Success { |
| + return "", fmt.Errorf("%w: customer update unsuccessful", registrar.ErrRefused) |
| + } |
| + return handle, nil |
| + } |
| + request := struct { |
| + contactFields |
| + Name contactName `json:"name"` |
| + Company string `json:"company_name,omitempty"` |
| + }{fields, identity, in.Company} |
| + var response struct { |
| + Handle string `json:"handle"` |
| + } |
| + if err := c.call(ctx, http.MethodPost, "/customers", request, &response); err != nil { |
| + return "", err |
| + } |
| + if response.Handle == "" { |
| + return "", errors.New("openprovider: missing customer handle") |
| + } |
| + return response.Handle, nil |
| +} |
| + |
| +func streetNumber(street, number string) (string, string) { |
| + if number != "" { |
| + return street, number |
| + } |
| + words := strings.Fields(street) |
| + numeric := func(s string) bool { |
| + if s == "" { |
| + return false |
| + } |
| + for _, ch := range s { |
| + if ch < '0' || ch > '9' { |
| + return false |
| + } |
| + } |
| + return true |
| + } |
| + if len(words) > 1 { |
| + if numeric(words[0]) { |
| + return strings.Join(words[1:], " "), words[0] |
| + } |
| + if numeric(words[len(words)-1]) { |
| + return strings.Join(words[:len(words)-1], " "), words[len(words)-1] |
| + } |
| + } |
| + return street, "" |
| +} |
| + |
| +type nameserver struct { |
| + Name string `json:"name"` |
| +} |
| + |
| +type domainRecord struct { |
| + ID int64 `json:"id"` |
| + Domain domainName `json:"domain"` |
| + Status string `json:"status"` |
| + Expires string `json:"expiration_date"` |
| + Nameservers []nameserver `json:"name_servers"` |
| + Deleted bool `json:"is_deleted"` |
| +} |
| + |
| +func (c *Client) Register(ctx context.Context, in registrar.Registration) (registrar.Registered, error) { |
| + d, err := splitDomain(in.Domain) |
| + if err != nil { |
| + return registrar.Registered{}, err |
| + } |
| + if in.Years < 1 || in.OwnerHandle == "" || len(in.Nameservers) == 0 { |
| + return registrar.Registered{}, fmt.Errorf("%w: incomplete registration", registrar.ErrRefused) |
| + } |
| + request := struct { |
| + Domain domainName `json:"domain"` |
| + Period int `json:"period"` |
| + Autorenew string `json:"autorenew"` |
| + Owner string `json:"owner_handle"` |
| + Admin string `json:"admin_handle"` |
| + Tech string `json:"tech_handle"` |
| + Billing string `json:"billing_handle"` |
| + Nameservers []nameserver `json:"name_servers"` |
| + Private bool `json:"is_private_whois_enabled"` |
| + }{Domain: d, Period: in.Years, Autorenew: "off", Owner: in.OwnerHandle, Admin: in.OwnerHandle, Tech: in.OwnerHandle, Billing: in.OwnerHandle, Private: true} |
| + for _, name := range in.Nameservers { |
| + request.Nameservers = append(request.Nameservers, nameserver{Name: name}) |
| + } |
| + // Openprovider has no registration idempotency key; in.Key is deliberately |
| + // unused. After an indeterminate outcome the caller must reconcile by Lookup. |
| + var response domainRecord |
| + err = c.call(ctx, http.MethodPost, "/domains", request, &response) |
| + var pe *providerError |
| + if errors.As(err, &pe) && errors.Is(err, registrar.ErrRefused) && (pe.code == 19006 || pe.code == 19007) { |
| + // These refusals mean nothing was registered. No other failure permits a |
| + // second registration request here (apart from the bounded 401 re-login). |
| + request.Private = false |
| + err = c.call(ctx, http.MethodPost, "/domains", request, &response) |
| + } |
| + if err != nil { |
| + return registrar.Registered{}, err |
| + } |
| + response.Domain = d |
| + response.Nameservers = request.Nameservers |
| + return response.registered() |
| +} |
| + |
| +func (c *Client) Lookup(ctx context.Context, domain string) (registrar.Registered, bool, error) { |
| + var response struct { |
| + Results *[]domainRecord `json:"results"` |
| + Total int `json:"total"` |
| + } |
| + if err := c.call(ctx, http.MethodGet, "/domains?full_name="+url.QueryEscape(domain), nil, &response); err != nil { |
| + return registrar.Registered{}, false, err |
| + } |
| + if response.Results == nil { |
| + return registrar.Registered{}, false, errors.New("openprovider: missing domain results") |
| + } |
| + records := *response.Results |
| + if len(records) == 0 && response.Total == 0 { |
| + return registrar.Registered{}, false, nil |
| + } |
| + if len(records) != 1 || records[0].Domain.Name+"."+records[0].Domain.Extension != domain { |
| + return registrar.Registered{}, false, errors.New("openprovider: unexpected domain results") |
| + } |
| + if records[0].Deleted { |
| + return registrar.Registered{}, false, nil |
| + } |
| + result, err := records[0].registered() |
| + return result, err == nil, err |
| +} |
| + |
| +func (r domainRecord) registered() (registrar.Registered, error) { |
| + // A queued registration is not proof of ownership. Keep the purchase pending. |
| + if r.ID <= 0 || r.Status != "ACT" { |
| + return registrar.Registered{}, fmt.Errorf("%w: registration is not confirmed active", registrar.ErrIndeterminate) |
| + } |
| + var expires time.Time |
| + for _, layout := range []string{time.RFC3339, "2006-01-02 15:04:05"} { |
| + if parsed, err := time.Parse(layout, r.Expires); err == nil { |
| + expires = parsed |
| + break |
| + } |
| + } |
| + if expires.IsZero() { |
| + return registrar.Registered{}, fmt.Errorf("%w: invalid registration expiry", registrar.ErrIndeterminate) |
| + } |
| + result := registrar.Registered{Domain: r.Domain.Name + "." + r.Domain.Extension, RegistrarID: strconv.FormatInt(r.ID, 10), Expires: expires} |
| + for _, ns := range r.Nameservers { |
| + result.Nameservers = append(result.Nameservers, ns.Name) |
| + } |
| + return result, nil |
| +} |
| + |
| +func (c *Client) Balance(ctx context.Context) (registrar.Money, error) { |
| + var response struct { |
| + Balance json.Number `json:"balance"` |
| + Settings struct { |
| + Currency string `json:"currency"` |
| + } `json:"settings"` |
| + } |
| + if err := c.call(ctx, http.MethodGet, "/resellers?with_settings=true", nil, &response); err != nil { |
| + return registrar.Money{}, err |
| + } |
| + return money(response.Settings.Currency, response.Balance) |
| +} |
| + |
| +func money(code string, amount json.Number) (registrar.Money, error) { |
| + unit, err := currency.ParseISO(code) |
| + if err != nil || code == "" { |
| + return registrar.Money{}, errors.New("openprovider: invalid currency") |
| + } |
| + scale, _ := currency.Standard.Rounding(unit) |
| + value, ok := new(big.Rat).SetString(string(amount)) |
| + if !ok { |
| + return registrar.Money{}, errors.New("openprovider: invalid monetary amount") |
| + } |
| + value.Mul(value, new(big.Rat).SetInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(scale)), nil))) |
| + // Round decimal amounts to minor units without passing through float64. |
| + sign := value.Sign() |
| + value.Abs(value) |
| + value.Add(value, big.NewRat(1, 2)) |
| + rounded := new(big.Int).Quo(value.Num(), value.Denom()) |
| + if sign < 0 { |
| + rounded.Neg(rounded) |
| + } |
| + if !rounded.IsInt64() { |
| + return registrar.Money{}, errors.New("openprovider: monetary amount overflows minor units") |
| + } |
| + return registrar.Money{Currency: strings.ToLower(code), Minor: rounded.Int64()}, nil |
| +} |
| + |
| +type providerError struct { |
| + kind error |
| + status, code int |
| + message string |
| +} |
| + |
| +func (e *providerError) Error() string { |
| + return fmt.Sprintf("openprovider: HTTP %d code %d: %s: %v", e.status, e.code, e.message, e.kind) |
| +} |
| +func (e *providerError) Unwrap() error { return e.kind } |
| + |
| +type envelope struct { |
| + Code *int `json:"code"` |
| + Description string `json:"desc"` |
| + Data json.RawMessage `json:"data"` |
| +} |
| + |
| +func (c *Client) bearer(ctx context.Context, invalid string) (string, error) { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + if c.token != "" && c.token != invalid { |
| + return c.token, nil |
| + } |
| + c.token = "" |
| + request := struct { |
| + Username string `json:"username"` |
| + Password string `json:"password"` |
| + }{c.username, c.password} |
| + payload, _ := json.Marshal(request) |
| + data, _, err := c.send(ctx, http.MethodPost, "/auth/login", payload, "") |
| + if err != nil { |
| + return "", err |
| + } |
| + var response struct { |
| + Token string `json:"token"` |
| + } |
| + if err := json.Unmarshal(data, &response); err != nil || response.Token == "" { |
| + return "", errors.New("openprovider: missing login token") |
| + } |
| + c.token = response.Token |
| + return c.token, nil |
| +} |
| + |
| +func (c *Client) call(ctx context.Context, method, path string, input, output any) error { |
| + var payload []byte |
| + if input != nil { |
| + var err error |
| + payload, err = json.Marshal(input) |
| + if err != nil { |
| + return errors.New("openprovider: cannot encode request") |
| + } |
| + } |
| + token, err := c.bearer(ctx, "") |
| + if err != nil { |
| + return err |
| + } |
| + for attempt := 0; attempt < 2; attempt++ { |
| + data, status, err := c.send(ctx, method, path, payload, token) |
| + if status == http.StatusUnauthorized && attempt == 0 { |
| + token, err = c.bearer(ctx, token) |
| + if err != nil { |
| + return err |
| + } |
| + continue |
| + } |
| + if err != nil { |
| + return err |
| + } |
| + if err := json.Unmarshal(data, output); err != nil { |
| + return responseError(method, path, "invalid response data") |
| + } |
| + return nil |
| + } |
| + return errors.New("openprovider: authentication failed") |
| +} |
| + |
| +func responseError(method, path, message string) error { |
| + if method == http.MethodPost && path == "/domains" { |
| + return fmt.Errorf("%w: openprovider: %s", registrar.ErrIndeterminate, message) |
| + } |
| + return fmt.Errorf("openprovider: %s", message) |
| +} |
| + |
| +func (c *Client) send(ctx context.Context, method, path string, payload []byte, token string) (json.RawMessage, int, error) { |
| + req, err := http.NewRequestWithContext(ctx, method, c.endpoint+path, bytes.NewReader(payload)) |
| + if err != nil { |
| + return nil, 0, errors.New("openprovider: invalid request") |
| + } |
| + req.Header.Set("Accept", "application/json") |
| + if payload != nil { |
| + req.Header.Set("Content-Type", "application/json") |
| + } |
| + if token != "" { |
| + req.Header.Set("Authorization", "Bearer "+token) |
| + } |
| + res, err := c.http.Do(req) |
| + if err != nil { |
| + // Transport errors can contain URLs or headers from a custom transport. |
| + return nil, 0, responseError(method, path, "request failed") |
| + } |
| + defer res.Body.Close() |
| + status := res.StatusCode |
| + raw, readErr := io.ReadAll(io.LimitReader(res.Body, 1<<20+1)) |
| + var answer envelope |
| + decodeErr := json.Unmarshal(raw, &answer) |
| + code := 0 |
| + if answer.Code != nil { |
| + code = *answer.Code |
| + } |
| + if status >= 500 || status < 200 || (status >= 300 && status < 400) { |
| + return nil, status, responseError(method, path, fmt.Sprintf("HTTP %d", status)) |
| + } |
| + if status >= 400 || (decodeErr == nil && answer.Code != nil && code != 0) { |
| + kind := registrar.ErrRefused |
| + if status < 400 && method == http.MethodPost && path == "/domains" && code != 19006 && code != 19007 { |
| + // A provider error inside HTTP 200 is not a definite refusal unless |
| + // its code documents that nothing was registered. |
| + kind = registrar.ErrIndeterminate |
| + } |
| + if code == 311 { |
| + kind = registrar.ErrUnavailable |
| + } |
| + message := answer.Description |
| + for _, secret := range []string{c.username, c.password, token} { |
| + if secret != "" { |
| + message = strings.ReplaceAll(message, secret, "[redacted]") |
| + } |
| + } |
| + return nil, status, &providerError{kind: kind, status: status, code: code, message: message} |
| + } |
| + if readErr != nil || len(raw) > 1<<20 || decodeErr != nil || answer.Code == nil || len(answer.Data) == 0 || string(answer.Data) == "null" { |
| + return nil, status, responseError(method, path, "invalid response") |
| + } |
| + return answer.Data, status, nil |
| +} |
diff --git a/internal/registrar/openprovider/client_test.go b/internal/registrar/openprovider/client_test.go| new file mode 100644 |
| index 000000000..8285616d1 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/client_test.go |
| @@ -0,0 +1,546 @@ |
| +package openprovider_test |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "net/http" |
| + "net/http/httptest" |
| + "os" |
| + "reflect" |
| + "strings" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registrar" |
| + "github.com/carlosframework/platform/internal/registrar/openprovider" |
| +) |
| + |
| +const password = "test-password-secret" |
| +const token = "20d65561c9636d262e59aec8582c20c7" |
| + |
| +func fixture(t *testing.T, name string) []byte { |
| + t.Helper() |
| + b, err := os.ReadFile("testdata/" + name + ".json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return b |
| +} |
| + |
| +func reply(t *testing.T, w http.ResponseWriter, name string) { |
| + t.Helper() |
| + w.Header().Set("Content-Type", "application/json") |
| + _, _ = w.Write(fixture(t, name)) |
| +} |
| + |
| +func body(t *testing.T, r *http.Request) map[string]any { |
| + t.Helper() |
| + var b map[string]any |
| + if err := json.NewDecoder(r.Body).Decode(&b); err != nil { |
| + t.Error(err) |
| + } |
| + return b |
| +} |
| + |
| +func newClient(t *testing.T, h http.HandlerFunc, timeout time.Duration) *openprovider.Client { |
| + t.Helper() |
| + s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + if r.URL.Path == "/v1/auth/login" { |
| + b := body(t, r) |
| + if r.Method != "POST" || b["username"] != "test-user" || b["password"] != password { |
| + t.Errorf("login request: %s %v", r.Method, b) |
| + } |
| + reply(t, w, "login") |
| + return |
| + } |
| + if r.Header.Get("Authorization") != "Bearer "+token { |
| + t.Error("missing bearer token") |
| + } |
| + h(w, r) |
| + })) |
| + t.Cleanup(s.Close) |
| + c, err := openprovider.New(openprovider.Config{BaseURL: s.URL + "/v1", Username: "test-user", Password: password, HTTP: &http.Client{Timeout: timeout}}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return c |
| +} |
| + |
| +func registration() registrar.Registration { |
| + return registrar.Registration{Domain: "shop.example", Years: 2, OwnerHandle: "XX123456-XX", Key: "purchase-id", Nameservers: []string{"ns1.example", "ns2.example", "ns3.example", "ns4.example"}} |
| +} |
| + |
| +func TestNewRequiresFields(t *testing.T) { |
| + for _, field := range []string{"BaseURL", "Username", "Password"} { |
| + cfg := openprovider.Config{BaseURL: "https://api.openprovider.eu/v1", Username: "user", Password: password} |
| + reflect.ValueOf(&cfg).Elem().FieldByName(field).SetString("") |
| + if _, err := openprovider.New(cfg); err == nil || !strings.Contains(err.Error(), field) { |
| + t.Errorf("%s: %v", field, err) |
| + } |
| + } |
| +} |
| + |
| +func TestCheckParsesAvailabilityAndCost(t *testing.T) { |
| + for _, premium := range []bool{false, true} { |
| + t.Run(fmt.Sprint(premium), func(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + b := body(t, r) |
| + if r.Method != "POST" || r.URL.Path != "/v1/domains/check" || b["with_price"] != true { |
| + t.Errorf("check: %s %s %v", r.Method, r.URL, b) |
| + } |
| + want := []any{map[string]any{"name": "shop", "extension": "example"}} |
| + if !reflect.DeepEqual(b["domains"], want) { |
| + t.Errorf("domains=%v", b["domains"]) |
| + } |
| + raw := fixture(t, "check") |
| + if premium { |
| + raw = []byte(strings.Replace(string(raw), `"is_premium": false`, `"is_premium": true`, 1)) |
| + } |
| + _, _ = w.Write(raw) |
| + }, time.Second) |
| + a, err := c.Check(context.Background(), "shop.example") |
| + want := registrar.Availability{Domain: "shop.example", Available: true, Premium: premium, Cost: registrar.Money{Currency: "eur", Minor: 899}} |
| + if err != nil || a != want { |
| + t.Fatalf("Check=%+v, %v; want %+v", a, err, want) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestRegisterSendsAutorenewOffAndNameservers(t *testing.T) { |
| + req := registration() |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + b := body(t, r) |
| + if r.Method != "POST" || r.URL.Path != "/v1/domains" { |
| + t.Errorf("register: %s %s", r.Method, r.URL) |
| + } |
| + if b["autorenew"] != "off" || b["period"] != float64(req.Years) || b["is_private_whois_enabled"] != true { |
| + t.Errorf("body=%v", b) |
| + } |
| + if !reflect.DeepEqual(b["domain"], map[string]any{"name": "shop", "extension": "example"}) { |
| + t.Errorf("domain=%v", b["domain"]) |
| + } |
| + for _, k := range []string{"owner_handle", "admin_handle", "tech_handle", "billing_handle"} { |
| + if b[k] != req.OwnerHandle { |
| + t.Errorf("%s=%v", k, b[k]) |
| + } |
| + } |
| + var want []any |
| + for _, n := range req.Nameservers { |
| + want = append(want, map[string]any{"name": n}) |
| + } |
| + if !reflect.DeepEqual(b["name_servers"], want) { |
| + t.Errorf("nameservers=%v", b["name_servers"]) |
| + } |
| + if r.Header.Get("Idempotency-Key") != "" || strings.Contains(fmt.Sprint(b), req.Key) { |
| + t.Error("invented provider idempotency") |
| + } |
| + reply(t, w, "register") |
| + }, time.Second) |
| + got, err := c.Register(context.Background(), req) |
| + expires := time.Date(2020, 4, 29, 17, 15, 19, 0, time.UTC) |
| + if err != nil || got.Domain != req.Domain || got.RegistrarID != "123456789" || !got.Expires.Equal(expires) || !reflect.DeepEqual(got.Nameservers, req.Nameservers) { |
| + t.Fatalf("Register=%+v, %v", got, err) |
| + } |
| +} |
| + |
| +func TestRegisterTimeoutIsIndeterminate(t *testing.T) { |
| + var calls atomic.Int32 |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + calls.Add(1) |
| + time.Sleep(100 * time.Millisecond) |
| + reply(t, w, "register") |
| + }, 50*time.Millisecond) |
| + _, err := c.Register(context.Background(), registration()) |
| + if !errors.Is(err, registrar.ErrIndeterminate) || calls.Load() != 1 { |
| + t.Fatalf("error=%v calls=%d", err, calls.Load()) |
| + } |
| +} |
| + |
| +func TestRegisterTakenIsUnavailable(t *testing.T) { |
| + for _, status := range []int{200, 400, 409} { |
| + t.Run(fmt.Sprint(status), func(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(status); reply(t, w, "taken") }, time.Second) |
| + if _, err := c.Register(context.Background(), registration()); !errors.Is(err, registrar.ErrUnavailable) { |
| + t.Fatalf("error=%v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestReloginOnce401(t *testing.T) { |
| + for _, always := range []bool{false, true} { |
| + t.Run(fmt.Sprint(always), func(t *testing.T) { |
| + var logins, calls atomic.Int32 |
| + s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + if r.URL.Path == "/v1/auth/login" { |
| + n := logins.Add(1) |
| + fmt.Fprintf(w, `{"code":0,"data":{"token":"token-%d"}}`, n) |
| + return |
| + } |
| + n := calls.Add(1) |
| + if r.Header.Get("Authorization") != fmt.Sprintf("Bearer token-%d", n) { |
| + t.Error("retry did not use refreshed token") |
| + } |
| + if b := body(t, r); b["autorenew"] != "off" { |
| + t.Error("retry lost request body") |
| + } |
| + if always || n == 1 { |
| + w.WriteHeader(401) |
| + return |
| + } |
| + reply(t, w, "register") |
| + })) |
| + defer s.Close() |
| + c, err := openprovider.New(openprovider.Config{BaseURL: s.URL, Username: "user", Password: password}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + _, err = c.Register(context.Background(), registration()) |
| + if (err != nil) != always || logins.Load() != 2 || calls.Load() != 2 { |
| + t.Fatalf("err=%v logins=%d calls=%d", err, logins.Load(), calls.Load()) |
| + } |
| + if always && !errors.Is(err, registrar.ErrRefused) { |
| + t.Fatalf("second 401=%v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestStringRedactsSecrets(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { reply(t, w, "balance") }, time.Second) |
| + if _, err := c.Balance(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + got := fmt.Sprintf("%v %#v", c, c) |
| + if strings.Contains(got, password) || strings.Contains(got, token) || !strings.HasPrefix(got, "openprovider(") || c.String() != c.GoString() { |
| + t.Fatalf("format=%s", got) |
| + } |
| +} |
| + |
| +func TestPrivacyRefusalRetriesOnce(t *testing.T) { |
| + for _, code := range []int{19006, 19007} { |
| + for _, again := range []bool{false, true} { |
| + t.Run(fmt.Sprintf("%d/%v", code, again), func(t *testing.T) { |
| + var calls atomic.Int32 |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + n := calls.Add(1) |
| + b := body(t, r) |
| + if b["is_private_whois_enabled"] != (n == 1) { |
| + t.Errorf("attempt %d privacy=%v", n, b["is_private_whois_enabled"]) |
| + } |
| + if n == 1 || again { |
| + w.WriteHeader(400) |
| + fmt.Fprintf(w, `{"code":%d,"desc":"privacy not supported"}`, code) |
| + return |
| + } |
| + reply(t, w, "register") |
| + }, time.Second) |
| + _, err := c.Register(context.Background(), registration()) |
| + if (err != nil) != again || calls.Load() != 2 { |
| + t.Fatalf("error=%v calls=%d", err, calls.Load()) |
| + } |
| + if again && !errors.Is(err, registrar.ErrRefused) { |
| + t.Fatal(err) |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +func TestRegisterFailures(t *testing.T) { |
| + for _, tc := range []struct { |
| + name string |
| + status int |
| + response string |
| + want error |
| + }{ |
| + {"server", 503, `{"code":19006,"desc":"privacy"}`, registrar.ErrIndeterminate}, |
| + {"malformed", 200, `{"code":0,"data":`, registrar.ErrIndeterminate}, |
| + {"empty", 200, `{}`, registrar.ErrIndeterminate}, |
| + {"missing-data", 200, `{"code":0,"data":{}}`, registrar.ErrIndeterminate}, |
| + {"pending", 200, `{"code":0,"data":{"id":123,"status":"REQ"}}`, registrar.ErrIndeterminate}, |
| + {"refused", 422, `{"code":112,"desc":"address number required"}`, registrar.ErrRefused}, |
| + {"non-json-refusal", 403, `Forbidden`, registrar.ErrRefused}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + var calls atomic.Int32 |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + calls.Add(1) |
| + w.WriteHeader(tc.status) |
| + fmt.Fprint(w, tc.response) |
| + }, time.Second) |
| + _, err := c.Register(context.Background(), registration()) |
| + if !errors.Is(err, tc.want) || calls.Load() != 1 { |
| + t.Fatalf("error=%v calls=%d", err, calls.Load()) |
| + } |
| + if tc.name == "refused" && !strings.Contains(err.Error(), "address number required") { |
| + t.Fatal(err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func contact() registrar.Contact { |
| + return registrar.Contact{FirstName: "Test", LastName: "Person", Company: "Example company", Email: "alex@example.com", PhoneCountryCode: "44", Phone: "2079460000", Street: "Example Street", HouseNumber: "12A", City: "London", PostalCode: "SW1A 1AA", Country: "GB"} |
| +} |
| + |
| +func TestEnsureContact(t *testing.T) { |
| + for _, change := range []string{"new", "mutable", "FirstName", "LastName", "Company"} { |
| + t.Run(change, func(t *testing.T) { |
| + in := contact() |
| + existing := "XX123456-XX" |
| + if change == "new" { |
| + existing = "" |
| + } else if change != "mutable" { |
| + reflect.ValueOf(&in).Elem().FieldByName(change).SetString("Changed") |
| + } |
| + var calls []string |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + calls = append(calls, r.Method+" "+r.URL.Path) |
| + if r.Method == "GET" { |
| + reply(t, w, "contact-get") |
| + return |
| + } |
| + b := body(t, r) |
| + if b["email"] != in.Email { |
| + t.Errorf("email=%v", b["email"]) |
| + } |
| + wantPhone := map[string]any{"country_code": "+44", "area_code": "207", "subscriber_number": "9460000"} |
| + if !reflect.DeepEqual(b["phone"], wantPhone) { |
| + t.Errorf("phone=%v", b["phone"]) |
| + } |
| + wantAddress := map[string]any{"street": "Example Street", "number": "12A", "city": "London", "zipcode": "SW1A 1AA", "country": "GB"} |
| + if !reflect.DeepEqual(b["address"], wantAddress) { |
| + t.Errorf("address=%v", b["address"]) |
| + } |
| + if r.Method == "PUT" { |
| + if _, ok := b["name"]; ok { |
| + t.Error("PUT contains immutable name") |
| + } |
| + if _, ok := b["company_name"]; ok { |
| + t.Error("PUT contains immutable company") |
| + } |
| + reply(t, w, "contact-update") |
| + } else { |
| + if !reflect.DeepEqual(b["name"], map[string]any{"first_name": in.FirstName, "last_name": in.LastName}) || b["company_name"] != in.Company { |
| + t.Errorf("identity=%v", b) |
| + } |
| + fmt.Fprint(w, `{"code":0,"data":{"handle":"NEW-HANDLE"}}`) |
| + } |
| + }, time.Second) |
| + got, err := c.EnsureContact(context.Background(), existing, in) |
| + want := []string{"POST /v1/customers"} |
| + wantHandle := "NEW-HANDLE" |
| + if change == "mutable" { |
| + want = []string{"GET /v1/customers/XX123456-XX", "PUT /v1/customers/XX123456-XX"} |
| + wantHandle = existing |
| + } else if change != "new" { |
| + want = append([]string{"GET /v1/customers/XX123456-XX"}, want...) |
| + } |
| + if err != nil || got != wantHandle || !reflect.DeepEqual(calls, want) { |
| + t.Fatalf("handle=%q err=%v calls=%v", got, err, calls) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestContactAddressAndShortPhone(t *testing.T) { |
| + for _, tc := range []struct{ street, number, wantStreet, wantNumber, phone, area, subscriber string }{ |
| + {"12 Example Street", "", "Example Street", "12", "12345", "1", "2345"}, |
| + {"Example Street 12", "", "Example Street", "12", "123456", "12", "3456"}, |
| + {"Example Street", "", "Example Street", "", "1234", "", "1234"}, |
| + {"Example Street", "7B", "Example Street", "7B", "123", "", "123"}, |
| + } { |
| + t.Run(tc.street+tc.phone, func(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + b := body(t, r) |
| + a := b["address"].(map[string]any) |
| + p := b["phone"].(map[string]any) |
| + if a["street"] != tc.wantStreet || (tc.wantNumber != "" && a["number"] != tc.wantNumber) { |
| + t.Errorf("address=%v", a) |
| + } |
| + if tc.wantNumber == "" { |
| + if _, ok := a["number"]; ok { |
| + t.Error("number must be omitted") |
| + } |
| + } |
| + if p["area_code"] != tc.area || p["subscriber_number"] != tc.subscriber { |
| + t.Errorf("phone=%v", p) |
| + } |
| + reply(t, w, "contact-create") |
| + }, time.Second) |
| + in := contact() |
| + in.Street, in.HouseNumber, in.Phone = tc.street, tc.number, tc.phone |
| + if _, err := c.EnsureContact(context.Background(), "", in); err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestLookupAndBalance(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + if r.Method != "GET" { |
| + t.Errorf("method=%s", r.Method) |
| + } |
| + switch r.URL.Path { |
| + case "/v1/domains": |
| + if r.URL.Query().Get("full_name") == "shop.example" { |
| + reply(t, w, "lookup") |
| + } else { |
| + fmt.Fprint(w, `{"code":0,"data":{"results":[],"total":0}}`) |
| + } |
| + case "/v1/resellers": |
| + if r.URL.Query().Get("with_settings") != "true" { |
| + t.Error("missing settings") |
| + } |
| + reply(t, w, "balance") |
| + default: |
| + t.Errorf("path=%s", r.URL.Path) |
| + } |
| + }, time.Second) |
| + got, found, err := c.Lookup(context.Background(), "shop.example") |
| + if err != nil || !found || got.Domain != "shop.example" || got.RegistrarID != "123456789" || got.Expires.IsZero() || !reflect.DeepEqual(got.Nameservers, []string{"ns1.example.com"}) { |
| + t.Fatalf("lookup=%+v %v %v", got, found, err) |
| + } |
| + if _, found, err := c.Lookup(context.Background(), "missing.example"); err != nil || found { |
| + t.Fatalf("missing=%v %v", found, err) |
| + } |
| + balance, err := c.Balance(context.Background()) |
| + if err != nil || balance != (registrar.Money{Currency: "eur", Minor: 9999900}) { |
| + t.Fatalf("balance=%+v %v", balance, err) |
| + } |
| +} |
| + |
| +func TestLookupCannotConfirmPendingOrDeleted(t *testing.T) { |
| + for _, tc := range []struct { |
| + name, old, new string |
| + wantErr bool |
| + }{ |
| + {"pending", `"status": "ACT"`, `"status": "REQ"`, true}, |
| + {"deleted", `"is_deleted": false`, `"is_deleted": true`, false}, |
| + {"wrong-name", `"name": "shop"`, `"name": "other"`, true}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + fmt.Fprint(w, strings.Replace(string(fixture(t, "lookup")), tc.old, tc.new, 1)) |
| + }, time.Second) |
| + _, found, err := c.Lookup(context.Background(), "shop.example") |
| + if found || (err != nil) != tc.wantErr { |
| + t.Fatalf("found=%v err=%v", found, err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestMoneyConversionAndInvalidResponses(t *testing.T) { |
| + for _, tc := range []struct { |
| + currency, amount string |
| + minor int64 |
| + bad bool |
| + }{ |
| + {"EUR", "8.99", 899, false}, {"USD", "1.005", 101, false}, {"JPY", "899", 899, false}, |
| + {"KWD", "1.234", 1234, false}, {"EUR", "-2.50", -250, false}, |
| + {"EUR", "92233720368547758.07", 9223372036854775807, false}, |
| + {"EUR", "92233720368547758.08", 0, true}, {"EUR", "null", 0, true}, |
| + {"ZZZ", "8.99", 0, true}, {"", "8.99", 0, true}, |
| + } { |
| + t.Run(tc.currency+tc.amount, func(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + fmt.Fprintf(w, `{"code":0,"data":{"balance":%s,"settings":{"currency":%q}}}`, tc.amount, tc.currency) |
| + }, time.Second) |
| + got, err := c.Balance(context.Background()) |
| + if (err != nil) != tc.bad || (!tc.bad && (got.Minor != tc.minor || got.Currency != strings.ToLower(tc.currency))) { |
| + t.Fatalf("money=%+v err=%v", got, err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestContactRefusals(t *testing.T) { |
| + for _, tc := range []struct { |
| + name, handle, response string |
| + status int |
| + }{ |
| + {"missing-identity", "XX123456-XX", `{"code":0,"data":{}}`, 200}, |
| + {"missing-handle", "", `{"code":0,"data":{}}`, 200}, |
| + {"missing-number", "", `{"code":112,"desc":"address number required"}`, 400}, |
| + {"update-failed", "XX123456-XX", `{"code":0,"data":{"success":false}}`, 200}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + var calls atomic.Int32 |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + calls.Add(1) |
| + if r.Method == "GET" && tc.name == "update-failed" { |
| + reply(t, w, "contact-get") |
| + return |
| + } |
| + w.WriteHeader(tc.status) |
| + fmt.Fprint(w, tc.response) |
| + }, time.Second) |
| + if handle, err := c.EnsureContact(context.Background(), tc.handle, contact()); err == nil || handle != "" { |
| + t.Fatalf("handle=%q err=%v", handle, err) |
| + } |
| + if tc.name == "missing-identity" && calls.Load() != 1 { |
| + t.Fatalf("wrote after invalid identity: calls=%d", calls.Load()) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestRedirectDoesNotReplay(t *testing.T) { |
| + var calls atomic.Int32 |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + calls.Add(1) |
| + http.Redirect(w, r, "/v1/replayed", http.StatusTemporaryRedirect) |
| + }, time.Second) |
| + if _, err := c.Register(context.Background(), registration()); !errors.Is(err, registrar.ErrIndeterminate) || calls.Load() != 1 { |
| + t.Fatalf("error=%v calls=%d", err, calls.Load()) |
| + } |
| +} |
| + |
| +func TestErrorsRedactCredentials(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + w.WriteHeader(400) |
| + _ = json.NewEncoder(w).Encode(map[string]any{"code": 112, "desc": password + " " + token + " test-user address number required"}) |
| + }, time.Second) |
| + _, err := c.Register(context.Background(), registration()) |
| + if err == nil || !errors.Is(err, registrar.ErrRefused) { |
| + t.Fatalf("error=%v", err) |
| + } |
| + for _, secret := range []string{password, token, "test-user"} { |
| + if strings.Contains(err.Error(), secret) { |
| + t.Error("credential in error") |
| + } |
| + } |
| + if !strings.Contains(err.Error(), "address number required") { |
| + t.Fatal("lost provider message") |
| + } |
| +} |
| + |
| +func TestCheckTakenAndMultiLabelExtension(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + b := body(t, r) |
| + if !reflect.DeepEqual(b["domains"], []any{map[string]any{"name": "shop", "extension": "co.uk"}}) { |
| + t.Errorf("domain=%v", b["domains"]) |
| + } |
| + fmt.Fprint(w, `{"code":0,"data":{"results":[{"domain":"shop.co.uk","status":"active","is_premium":false}]}}`) |
| + }, time.Second) |
| + a, err := c.Check(context.Background(), "shop.co.uk") |
| + if err != nil || a.Available { |
| + t.Fatalf("Check=%+v %v", a, err) |
| + } |
| +} |
| + |
| +func TestRegisterUnknownProviderOutcomeIsIndeterminate(t *testing.T) { |
| + c := newClient(t, func(w http.ResponseWriter, r *http.Request) { |
| + fmt.Fprint(w, `{"code":199,"desc":"An unknown error has occurred"}`) |
| + }, time.Second) |
| + if _, err := c.Register(context.Background(), registration()); !errors.Is(err, registrar.ErrIndeterminate) { |
| + t.Fatal(err) |
| + } |
| +} |
diff --git a/internal/registrar/openprovider/testdata/README.md b/internal/registrar/openprovider/testdata/README.md| new file mode 100644 |
| index 000000000..0ea4ed412 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/README.md |
| @@ -0,0 +1,20 @@ |
| +# Openprovider response fixtures |
| + |
| +Source: [https://developer.openprovider.com/data/swagger.spec.js](https://developer.openprovider.com/data/swagger.spec.js), the schema loaded by the `/v1` reference on 2026-11-01. Each fixture starts from the named definition's `example`. The table records every substitution; other fields retain the reference values. |
| + |
| +| Fixture | Definition | Substitutions | |
| +| --- | --- | --- | |
| +| `login.json` | `authLoginResponse` | None; the token is the public example token. | |
| +| `check-reference.json` | `domainCheckDomainResponse` | None. | |
| +| `check.json` | `domainCheckDomainResponse` | `data.results[0]`: domain `example.com` → `shop.example`, status `active` → `free`, reason → empty; `price.reseller` → EUR 8.99. | |
| +| `contact-create.json` | `customerCreateCustomerResponse` | None. | |
| +| `contact-get.json` | `customerGetCustomerResponse` | None. | |
| +| `contact-update.json` | `customerUpdateCustomerResponse` | `data.success`: false → true. The schema uses a boolean; the customer quickstart's string `"true"` is not used. | |
| +| `register.json` | `domainCreateDomainResponse` | None. | |
| +| `lookup.json` | `domainListDomainsResponse` | First result's domain → `{name: "shop", extension: "example"}`, status `PRE` → `ACT`; total 999 → 1. | |
| +| `balance.json` | `resellerGetResellerResponse` | None. | |
| +| `taken.json` | `errorError` | Code 0 → 311; description → `Domain already registered or reserved`. | |
| + |
| +Code 311 comes from [https://openprovider.help/books/api-integrations/page/api-error-codes](https://openprovider.help/books/api-integrations/page/api-error-codes). Its description here is shortened. The same catalogue supplies privacy refusal codes 19006/19007 and unknown-error code 199 used in tests. |
| + |
| +Other test responses are synthetic variants for missing fields, pending or deleted registrations, errors, and empty results. Tests also change the premium flag and return a different customer handle to distinguish creation from update. These variants are not captured API responses. No live customer data or credentials are included. |
diff --git a/internal/registrar/openprovider/testdata/balance.json b/internal/registrar/openprovider/testdata/balance.json| new file mode 100644 |
| index 000000000..c05249623 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/balance.json |
| @@ -0,0 +1,399 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "additional_data": { |
| + "cif_nif_number": "12345678", |
| + "gstin": "123456789aaa", |
| + "internal_reference": "" |
| + }, |
| + "address": { |
| + "city": "Test city", |
| + "country": "NL", |
| + "number": "123", |
| + "state": "Testprovince", |
| + "street": "Test street", |
| + "suffix": "A", |
| + "zipcode": "1235 XX" |
| + }, |
| + "balance": 99999, |
| + "comments": "Some comment here", |
| + "company_name": "Example company", |
| + "contacts": [ |
| + { |
| + "additional_data": { |
| + "birth_city": "Test city", |
| + "birth_date": "1969-12-31", |
| + "social_security_number": "12326178T" |
| + }, |
| + "address": { |
| + "city": "Test city", |
| + "country": "NL", |
| + "number": "123", |
| + "state": "Testprovince", |
| + "street": "Test street", |
| + "suffix": "A", |
| + "zipcode": "1235 XX" |
| + }, |
| + "api_access_enabled": true, |
| + "api_client_ip_list": { |
| + "allow": [ |
| + "127.0.0.1" |
| + ], |
| + "deny": [ |
| + "127.0.0.1" |
| + ] |
| + }, |
| + "auth_type": "simple", |
| + "comments": "", |
| + "company_name": "Example company", |
| + "email": "test@mail.tld", |
| + "hash_changed_at": "2019-03-25 10:17:02", |
| + "id": 123456789, |
| + "is_active": false, |
| + "last_api_call_at": "2019-03-25 10:17:01", |
| + "last_login_at": "2019-04-12 11:58:39", |
| + "locale": "nl_NL", |
| + "name": { |
| + "first_name": "Test", |
| + "full_name": "Test Person", |
| + "initials": "T P", |
| + "last_name": "Person", |
| + "prefix": "Mr" |
| + }, |
| + "password_change_declined_at": "2019-03-23 12:32:15", |
| + "password_changed_at": "2019-03-25 10:17:00", |
| + "phone": { |
| + "area_code": "111", |
| + "country_code": "+03", |
| + "subscriber_number": "123456" |
| + }, |
| + "rcp_client_ip_list": { |
| + "allow": [ |
| + "127.0.0.1" |
| + ], |
| + "deny": [ |
| + "127.0.0.1" |
| + ] |
| + }, |
| + "reseller_id": 12345, |
| + "role": "admin", |
| + "secret_key": "SECRETKEYVALUE", |
| + "username": "user_name", |
| + "vat": "XX123456789X12" |
| + } |
| + ], |
| + "created_at": "2014-07-16 15:22:48", |
| + "email": "", |
| + "fax": { |
| + "area_code": "", |
| + "country_code": "", |
| + "subscriber_number": "" |
| + }, |
| + "id": 123456789, |
| + "locale": "nl_NL", |
| + "name": { |
| + "first_name": "Test", |
| + "full_name": "Test Person", |
| + "initials": "T P", |
| + "last_name": "Person", |
| + "prefix": "Mr" |
| + }, |
| + "phone": { |
| + "area_code": "111", |
| + "country_code": "+03", |
| + "subscriber_number": "123456" |
| + }, |
| + "reserved_balance": 1111.11, |
| + "settings": { |
| + "av_handle": "XX123456-XX", |
| + "claims_confirm_url": "http://www.domain.tld/confirm-tm_claims.php?domainId=%%domainId%%&domain=%%domain%%&code=%%authCode%%", |
| + "claims_email_subject": "Hi there! You need to accept registration for %%domain%%!", |
| + "claims_reseller_name": "Jon Doe's Webhosting!!", |
| + "claims_sender_email": "test@mail.tld", |
| + "currency": "EUR", |
| + "default_domain_billing_handle": "XX123456-XX", |
| + "default_domain_reseller_handle": "XX123456-XX", |
| + "foa_confirm_url": "", |
| + "foa_email_subject": "", |
| + "foa_reseller_name": "", |
| + "foa_sender_email": "", |
| + "foa_terms_conditions_url": "", |
| + "is_auto_renew_enabled": false, |
| + "is_custom_nses_enabled": false, |
| + "ive2_customized_body": "", |
| + "ive2_email_subject": "[URGENT REMINDER] Request for e-mail address verification", |
| + "ive_confirm_url": "http://icann-verification.registrar.eu/?email=%%email%%&authCode=%%authCode%%", |
| + "ive_customized_body": "", |
| + "ive_email_subject": "Request for e-mail address verification", |
| + "ive_reseller_name": "sdasd", |
| + "ive_sender_email": "do-not-reply@registrar.eu", |
| + "jurisdiction": "EU", |
| + "language": "EN", |
| + "maximum_credit": 20000, |
| + "maximum_credit_card_payment": 15000, |
| + "maximum_i_deal_payment": 1000000, |
| + "maximum_western_union_payment": 1000, |
| + "minimum_payment": 20, |
| + "minimum_western_union_payment": 500, |
| + "pay_methods": [ |
| + "ideal" |
| + ], |
| + "payment_methods": [ |
| + { |
| + "name": "ideal", |
| + "settings": { |
| + "limit": { |
| + "maximum": { |
| + "aud": 0, |
| + "bgn": 0, |
| + "brl": 0, |
| + "cad": 0, |
| + "chf": 0, |
| + "cny": 0, |
| + "czk": 0, |
| + "dkk": 0, |
| + "eek": 0, |
| + "eur": 0, |
| + "gbp": 0, |
| + "ghs": 0, |
| + "hkd": 0, |
| + "hrk": 0, |
| + "huf": 0, |
| + "idr": 0, |
| + "ils": 0, |
| + "inr": 0, |
| + "jpy": 0, |
| + "krw": 0, |
| + "lkr": 0, |
| + "ltl": 0, |
| + "lvl": 0, |
| + "mxn": 0, |
| + "myr": 0, |
| + "nok": 0, |
| + "nzd": 0, |
| + "php": 0, |
| + "pln": 0, |
| + "ron": 0, |
| + "rub": 0, |
| + "sek": 0, |
| + "sgd": 0, |
| + "thb": 0, |
| + "try": 0, |
| + "usd": 0, |
| + "zar": 0 |
| + }, |
| + "minimum": { |
| + "aud": 0, |
| + "bgn": 0, |
| + "brl": 0, |
| + "cad": 0, |
| + "chf": 0, |
| + "cny": 0, |
| + "czk": 0, |
| + "dkk": 0, |
| + "eek": 0, |
| + "eur": 0, |
| + "gbp": 0, |
| + "ghs": 0, |
| + "hkd": 0, |
| + "hrk": 0, |
| + "huf": 0, |
| + "idr": 0, |
| + "ils": 0, |
| + "inr": 0, |
| + "jpy": 0, |
| + "krw": 0, |
| + "lkr": 0, |
| + "ltl": 0, |
| + "lvl": 0, |
| + "mxn": 0, |
| + "myr": 0, |
| + "nok": 0, |
| + "nzd": 0, |
| + "php": 0, |
| + "pln": 0, |
| + "ron": 0, |
| + "rub": 0, |
| + "sek": 0, |
| + "sgd": 0, |
| + "thb": 0, |
| + "try": 0, |
| + "usd": 0, |
| + "zar": 0 |
| + } |
| + }, |
| + "transaction_fee": 0, |
| + "transaction_fee_absolute": 0 |
| + } |
| + } |
| + ], |
| + "preregistered_domain_priorities": "[]", |
| + "recurring_payment_methods": [ |
| + { |
| + "name": "ideal", |
| + "settings": { |
| + "limit": { |
| + "maximum": { |
| + "aud": 0, |
| + "bgn": 0, |
| + "brl": 0, |
| + "cad": 0, |
| + "chf": 0, |
| + "cny": 0, |
| + "czk": 0, |
| + "dkk": 0, |
| + "eek": 0, |
| + "eur": 0, |
| + "gbp": 0, |
| + "ghs": 0, |
| + "hkd": 0, |
| + "hrk": 0, |
| + "huf": 0, |
| + "idr": 0, |
| + "ils": 0, |
| + "inr": 0, |
| + "jpy": 0, |
| + "krw": 0, |
| + "lkr": 0, |
| + "ltl": 0, |
| + "lvl": 0, |
| + "mxn": 0, |
| + "myr": 0, |
| + "nok": 0, |
| + "nzd": 0, |
| + "php": 0, |
| + "pln": 0, |
| + "ron": 0, |
| + "rub": 0, |
| + "sek": 0, |
| + "sgd": 0, |
| + "thb": 0, |
| + "try": 0, |
| + "usd": 0, |
| + "zar": 0 |
| + }, |
| + "minimum": { |
| + "aud": 0, |
| + "bgn": 0, |
| + "brl": 0, |
| + "cad": 0, |
| + "chf": 0, |
| + "cny": 0, |
| + "czk": 0, |
| + "dkk": 0, |
| + "eek": 0, |
| + "eur": 0, |
| + "gbp": 0, |
| + "ghs": 0, |
| + "hkd": 0, |
| + "hrk": 0, |
| + "huf": 0, |
| + "idr": 0, |
| + "ils": 0, |
| + "inr": 0, |
| + "jpy": 0, |
| + "krw": 0, |
| + "lkr": 0, |
| + "ltl": 0, |
| + "lvl": 0, |
| + "mxn": 0, |
| + "myr": 0, |
| + "nok": 0, |
| + "nzd": 0, |
| + "php": 0, |
| + "pln": 0, |
| + "ron": 0, |
| + "rub": 0, |
| + "sek": 0, |
| + "sgd": 0, |
| + "thb": 0, |
| + "try": 0, |
| + "usd": 0, |
| + "zar": 0 |
| + } |
| + }, |
| + "transaction_fee": 0, |
| + "transaction_fee_absolute": 0 |
| + } |
| + } |
| + ], |
| + "renew_notification_days": [ |
| + 1 |
| + ], |
| + "renew_notification_every_week": false, |
| + "tac_contract": { |
| + "is_signed": false, |
| + "name": "opensign_terms_and_conditions", |
| + "signed_at": "2014-07-16 15:22:48", |
| + "type": "opensign" |
| + }, |
| + "tags": [ |
| + "VIPCUSTOMER" |
| + ], |
| + "transaction_fee": { |
| + "bank": 0, |
| + "credit_card": 3, |
| + "ideal": 0, |
| + "paypal": 5, |
| + "western_union": 0, |
| + "yandex": 5 |
| + }, |
| + "type": "normal" |
| + }, |
| + "statistics": { |
| + "currency": { |
| + "modified": "2010-08-01 9:30:54" |
| + }, |
| + "customer": { |
| + "modified": "2019-05-03 13:23:01", |
| + "total": 999 |
| + }, |
| + "dns": { |
| + "total": 999 |
| + }, |
| + "domain": { |
| + "by_status": { |
| + "act": 7, |
| + "fai": 419, |
| + "nsr": 0, |
| + "pen": 0, |
| + "rej": 5, |
| + "req": 15 |
| + }, |
| + "total": 999 |
| + }, |
| + "level": 3, |
| + "license": { |
| + "total": 999 |
| + }, |
| + "spam_experts": { |
| + "activated_at": "2012-10-29 10:48:30", |
| + "created_at": "2012-10-29 10:48:30", |
| + "exists": false, |
| + "expired_at": "2016-04-05 8:50:34", |
| + "incoming_count": 0, |
| + "incoming_limit": 10, |
| + "outgoing_count": 0, |
| + "outgoing_limit": 1, |
| + "status": "deleted", |
| + "with_outgoing_filter": false |
| + }, |
| + "ssl": { |
| + "by_status": { |
| + "act": 7, |
| + "fai": 419, |
| + "nsr": 0, |
| + "pen": 0, |
| + "rej": 5, |
| + "req": 15 |
| + }, |
| + "total": 999 |
| + } |
| + }, |
| + "status": "new", |
| + "tier": 3, |
| + "vat": "", |
| + "vatperc": 21 |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/check-reference.json b/internal/registrar/openprovider/testdata/check-reference.json| new file mode 100644 |
| index 000000000..1e4d7d811 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/check-reference.json |
| @@ -0,0 +1,32 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "results": [ |
| + { |
| + "claim_key": "", |
| + "domain": "example.com", |
| + "is_premium": false, |
| + "premium": { |
| + "currency": "USD", |
| + "price": { |
| + "create": 0 |
| + } |
| + }, |
| + "price": { |
| + "product": { |
| + "currency": "USD", |
| + "price": 8.06 |
| + }, |
| + "reseller": { |
| + "currency": "USD", |
| + "price": 8.06 |
| + } |
| + }, |
| + "reason": "Domain exists", |
| + "status": "active", |
| + "whois": "" |
| + } |
| + ] |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/check.json b/internal/registrar/openprovider/testdata/check.json| new file mode 100644 |
| index 000000000..3c40b5859 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/check.json |
| @@ -0,0 +1,32 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "results": [ |
| + { |
| + "claim_key": "", |
| + "domain": "shop.example", |
| + "is_premium": false, |
| + "premium": { |
| + "currency": "USD", |
| + "price": { |
| + "create": 0 |
| + } |
| + }, |
| + "price": { |
| + "product": { |
| + "currency": "USD", |
| + "price": 8.06 |
| + }, |
| + "reseller": { |
| + "currency": "EUR", |
| + "price": 8.99 |
| + } |
| + }, |
| + "reason": "", |
| + "status": "free", |
| + "whois": "" |
| + } |
| + ] |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/contact-create.json b/internal/registrar/openprovider/testdata/contact-create.json| new file mode 100644 |
| index 000000000..866f0aa5c |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/contact-create.json |
| @@ -0,0 +1,7 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "handle": "XX123456-XX" |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/contact-get.json b/internal/registrar/openprovider/testdata/contact-get.json| new file mode 100644 |
| index 000000000..80249a7a0 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/contact-get.json |
| @@ -0,0 +1,124 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "additional_data": { |
| + "attached_files": [ |
| + { |
| + "description": "My passport scan", |
| + "doc_type": "passport", |
| + "path": "https://drive.google.com/open?id=1EclbGeo8Y3UWg3KSF7ebmwcK7ddLTtC7m3aHZ1qMnjE" |
| + } |
| + ], |
| + "birth_address": "test street 45", |
| + "birth_city": "Test city", |
| + "birth_country": "NL", |
| + "birth_date": "1970-01-01", |
| + "birth_state": "Testprovince", |
| + "birth_zipcode": "123", |
| + "company_registration_city": "Testcity", |
| + "company_registration_number": "XX123456789X04", |
| + "company_registration_subscription_date": "2000-01-01", |
| + "company_url": "https://openprovider.com", |
| + "headquarters_address": "Test street 5", |
| + "headquarters_city": "Testcity", |
| + "headquarters_country": "NL", |
| + "headquarters_state": "Testprovince", |
| + "headquarters_zipcode": "123", |
| + "passport_number": "123456", |
| + "social_security_number": "6543210", |
| + "trading_name": "Openprovider" |
| + }, |
| + "address": { |
| + "city": "Test city", |
| + "country": "NL", |
| + "number": "123", |
| + "state": "Testprovince", |
| + "street": "Test street", |
| + "suffix": "A", |
| + "zipcode": "1235 XX" |
| + }, |
| + "comments": "Some comment here", |
| + "comments_last_changed_at": "2014-05-08 19:04:11", |
| + "company_name": "Example company", |
| + "deleted_at": "0000-00-00 00:00:00", |
| + "email": "test@mail.tld", |
| + "email_verification_status": "ACT", |
| + "extension_additional_data": [ |
| + { |
| + "data": { |
| + "admin_type": "1", |
| + "applicant_purpose": "P3", |
| + "birth_date": "1970-01-01", |
| + "company_name_cyrillic": "Example company", |
| + "company_name_latin": "Example company", |
| + "company_registration_number": "XX123456789X11", |
| + "contact_title": "CEO", |
| + "country_of_citizenship": "NL", |
| + "customer_uin": "", |
| + "ens_auth_id": "", |
| + "ens_key": "", |
| + "first_name_cyrillic": "Test", |
| + "first_name_latin": "Test", |
| + "hr_member": "", |
| + "industry_class": "19", |
| + "is_private_enterpreneur": "", |
| + "last_name_cyrillic": "Person", |
| + "last_name_latin": "Person", |
| + "legal_address_cyrillic": "13245 Country, City, street, 2", |
| + "legal_type": "FCORP", |
| + "middle_name_cyrillic": "Nikolaevich", |
| + "middle_name_latin": "Nikolaevich", |
| + "mobile_phone_number": "+7 (123) 456-78-90", |
| + "music_nexus_connection_to_music": "MSCN", |
| + "music_nexus_registry_policies_attestation": "YES", |
| + "nexus_category": "C31", |
| + "org_type": "1", |
| + "passport_issue_date": "2009-01-11", |
| + "passport_issuer": "Issuer name", |
| + "passport_number": "12345678", |
| + "passport_series": "1234", |
| + "postal_address_cyrillic": "12345 Country, City, street, 1", |
| + "social_security_number": "X123455123X", |
| + "tax_payer_number": "1345678", |
| + "uin": "12345-6", |
| + "user_type": "Individual", |
| + "vat": "XX123456789X12", |
| + "website": "http://example.com", |
| + "whois_email": "test@mail.tld" |
| + }, |
| + "name": "ru" |
| + } |
| + ], |
| + "fax": { |
| + "area_code": "", |
| + "country_code": "", |
| + "subscriber_number": "" |
| + }, |
| + "handle": "XX123456-XX", |
| + "id": 123456789, |
| + "inn": "123456789", |
| + "is_deleted": false, |
| + "locale": "nl_NL", |
| + "name": { |
| + "first_name": "Test", |
| + "full_name": "Test Person", |
| + "initials": "T P", |
| + "last_name": "Person", |
| + "prefix": "Mr" |
| + }, |
| + "phone": { |
| + "area_code": "111", |
| + "country_code": "+03", |
| + "subscriber_number": "123456" |
| + }, |
| + "reseller_id": 5349, |
| + "tags": [ |
| + { |
| + "key": "customer", |
| + "value": "VIP" |
| + } |
| + ], |
| + "vat": "XX123456789X11" |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/contact-update.json b/internal/registrar/openprovider/testdata/contact-update.json| new file mode 100644 |
| index 000000000..53ab3a938 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/contact-update.json |
| @@ -0,0 +1,7 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "success": true |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/login.json b/internal/registrar/openprovider/testdata/login.json| new file mode 100644 |
| index 000000000..c9cbdd4f7 |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/login.json |
| @@ -0,0 +1,8 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "reseller_id": 123456, |
| + "token": "20d65561c9636d262e59aec8582c20c7" |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/lookup.json b/internal/registrar/openprovider/testdata/lookup.json| new file mode 100644 |
| index 000000000..c430e7d5e |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/lookup.json |
| @@ -0,0 +1,192 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "results": [ |
| + { |
| + "abuse_details": { |
| + "abuse_id": 0, |
| + "is_domain_held": false, |
| + "message": "" |
| + }, |
| + "active_date": "2019-01-27 0:55:17", |
| + "additional_data": { |
| + "abogado_acceptance": "", |
| + "admin_sing_pass_id": "", |
| + "ae_acceptance": "1", |
| + "allocation_token": "", |
| + "auth_code": "", |
| + "bank_acceptance": "", |
| + "company_registration_number": "XX123456789X01", |
| + "consent_for_publishing": "", |
| + "coop_acceptance": "1", |
| + "customer_uin": "374892173498127349", |
| + "customer_uin_doc_type": { |
| + "description": "Singapore Personal Access ID", |
| + "doc_type": "singpass" |
| + }, |
| + "dk_acceptance": "", |
| + "domain_name_variants": [ |
| + "xn--\u0434\u043e\u043c\u0435\u043d.cat" |
| + ], |
| + "eligibility_type": "", |
| + "eligibility_type_relationship": "", |
| + "es_annex_acceptance": "1", |
| + "ftld_token": "", |
| + "gay_donation_acceptance": "1", |
| + "gay_rights_protection_acceptance": "1", |
| + "id_number": "123456789X", |
| + "id_type": "", |
| + "idn_script": "SPA", |
| + "iisse_acceptance": "", |
| + "insurance_acceptance": "", |
| + "intended_use": "generic", |
| + "law_acceptance": "", |
| + "legal_type": "Individual", |
| + "maintainer": "", |
| + "membership_id": "A", |
| + "mobile_phone_number_verification": "", |
| + "ngo_ong_eligibility_acceptance": "", |
| + "ngo_ong_policy_acceptance": "", |
| + "passport_number": "X123456", |
| + "rurf_blocked_domains": "", |
| + "self_service": "1", |
| + "trade_auth_key": "", |
| + "trademark": "1", |
| + "trademark_id": "", |
| + "travel_acceptance": "1", |
| + "vat": "11843009X", |
| + "verification_code": "", |
| + "vote_acceptance": "", |
| + "voto_acceptance": "" |
| + }, |
| + "admin_handle": "XX123456-XX", |
| + "api_history": [ |
| + { |
| + "cmd": "deleteDomainRequest", |
| + "created_at": "2018-09-05 13:58:55", |
| + "domain_id": 12345678, |
| + "in": "", |
| + "out": "" |
| + } |
| + ], |
| + "application_id": "A743C511084404F31B15757DC979A1412-ABI", |
| + "application_mode": "", |
| + "application_mode_expiration_date": "", |
| + "application_mode_title": "", |
| + "application_notice_id": "983bdc1a0000100000188801724", |
| + "application_smd": "", |
| + "auth_code": "1a2b3c4d5e6f", |
| + "autorenew": "default", |
| + "billing_handle": "XX123456-XX", |
| + "can_renew": false, |
| + "comments": "", |
| + "comments_last_changed_at": "2018-01-30 14:37:49", |
| + "creation_date": "2013-07-04 17:14:44", |
| + "delete_status": "quarantine", |
| + "deleted_at": "0000-00-00 00:00:00", |
| + "dnssec": "unsigned", |
| + "dnssec_keys": [ |
| + { |
| + "alg": 8, |
| + "flags": 257, |
| + "protocol": 3, |
| + "pub_key": "WSgigdu8545g96", |
| + "readonly": 1 |
| + } |
| + ], |
| + "domain": { |
| + "name": "shop", |
| + "extension": "example" |
| + }, |
| + "expiration_date": "2014-07-04 17:14:44", |
| + "hard_quarantine_expiry_date": "", |
| + "has_active_sectigo_zone": false, |
| + "has_history": false, |
| + "history": [ |
| + { |
| + "contents": "Domain: test-example.tldAction: registration succeededStatus: ACTOrder date: 2018-01-30Activation date: 2018-01-30Renewal date: 2019-01-27Expiration date: 2019-01-29Comments: registration of this domain has succeeded Nameserver addresses are automatically resolved by system; Nameserver IP addresses are only saved for glue records", |
| + "domain": "example.com", |
| + "ip": "12.123.3.12", |
| + "subject": "Sent status e-mail to admin@someemail.nl", |
| + "timestamp": "2018-01-30T14:38:45+01:00", |
| + "type": "I" |
| + } |
| + ], |
| + "id": 123456789, |
| + "internal_auth_code": "1a2b3c4d5e6f", |
| + "is_abusive": false, |
| + "is_client_hold_enabled": "no", |
| + "is_deleted": false, |
| + "is_dnssec_enabled": false, |
| + "is_hosted_whois": false, |
| + "is_lockable": false, |
| + "is_locked": false, |
| + "is_parked": false, |
| + "is_premium": false, |
| + "is_private_whois_allowed": false, |
| + "is_private_whois_enabled": false, |
| + "is_sectigo_dns_enabled": false, |
| + "is_spamexperts_enabled": false, |
| + "last_changed": "2014-04-18 7:13:05", |
| + "modify_owner_allowed": false, |
| + "name_servers": [ |
| + { |
| + "ip": "12.3.123.121", |
| + "ip6": "1s23:123:123:f", |
| + "name": "ns1.example.com", |
| + "seq_nr": 1 |
| + } |
| + ], |
| + "ns_group": "dns-openprovider", |
| + "ns_template_id": 0, |
| + "ns_template_name": "", |
| + "nsgroup_id": 1, |
| + "order_date": "2013-07-04 17:14:44", |
| + "owner": { |
| + "company_name": "Example company", |
| + "full_name": "Test Van Person" |
| + }, |
| + "owner_company_name": "Company Name", |
| + "owner_handle": "XX123456-XX", |
| + "quarantine_expiration_date": "", |
| + "registry_expiration_date": "2020-01-29 0:00:00", |
| + "registry_statuses": { |
| + "client_hold": { |
| + "is_changeable": false, |
| + "value": 0 |
| + }, |
| + "client_transfer_prohibited": { |
| + "is_changeable": false, |
| + "value": 0 |
| + } |
| + }, |
| + "renew": 2, |
| + "renewal_date": "2022-01-01 0:00:00", |
| + "reseller_handle": "XX123456-XX", |
| + "reseller_id": 12345, |
| + "restorable_until": "", |
| + "scheduled_at": "", |
| + "scheduled_from": "", |
| + "soft_quarantine_expiry_date": "", |
| + "status": "ACT", |
| + "tech_handle": "XX123456-XX", |
| + "trade_allowed": false, |
| + "trade_auth_code_required": "no", |
| + "transfer_auth_code_required": "yes", |
| + "transfer_cancel_supported": false, |
| + "type": "NEW", |
| + "unit": "y", |
| + "use_domicile": false, |
| + "verification_email_exp_date": "0000-00-00 00:00:00", |
| + "verification_email_name": "test@example.com", |
| + "verification_email_status": "not verified", |
| + "verification_email_status_description": "-", |
| + "whois_privacy_data": { |
| + "expiration_date": "2020-04-29 17:15:19" |
| + } |
| + } |
| + ], |
| + "total": 1 |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/register.json b/internal/registrar/openprovider/testdata/register.json| new file mode 100644 |
| index 000000000..0a90de3db |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/register.json |
| @@ -0,0 +1,62 @@ |
| +{ |
| + "code": 0, |
| + "data": { |
| + "activation_date": "2019-04-29 17:15:19", |
| + "additional_data": { |
| + "abogado_acceptance": "", |
| + "admin_sing_pass_id": "", |
| + "ae_acceptance": "1", |
| + "allocation_token": "", |
| + "auth_code": "", |
| + "bank_acceptance": "", |
| + "company_registration_number": "XX123456789X01", |
| + "consent_for_publishing": "", |
| + "coop_acceptance": "1", |
| + "customer_uin": "374892173498127349", |
| + "customer_uin_doc_type": { |
| + "description": "Singapore Personal Access ID", |
| + "doc_type": "singpass" |
| + }, |
| + "dk_acceptance": "", |
| + "domain_name_variants": [ |
| + "xn--\u0434\u043e\u043c\u0435\u043d.cat" |
| + ], |
| + "eligibility_type": "", |
| + "eligibility_type_relationship": "", |
| + "es_annex_acceptance": "1", |
| + "ftld_token": "", |
| + "gay_donation_acceptance": "1", |
| + "gay_rights_protection_acceptance": "1", |
| + "id_number": "123456789X", |
| + "id_type": "", |
| + "idn_script": "SPA", |
| + "iisse_acceptance": "", |
| + "insurance_acceptance": "", |
| + "intended_use": "generic", |
| + "law_acceptance": "", |
| + "legal_type": "Individual", |
| + "maintainer": "", |
| + "membership_id": "A", |
| + "mobile_phone_number_verification": "", |
| + "ngo_ong_eligibility_acceptance": "", |
| + "ngo_ong_policy_acceptance": "", |
| + "passport_number": "X123456", |
| + "rurf_blocked_domains": "", |
| + "self_service": "1", |
| + "trade_auth_key": "", |
| + "trademark": "1", |
| + "trademark_id": "", |
| + "travel_acceptance": "1", |
| + "vat": "11843009X", |
| + "verification_code": "", |
| + "vote_acceptance": "", |
| + "voto_acceptance": "" |
| + }, |
| + "auth_code": "12345678", |
| + "expiration_date": "2020-04-29 17:15:19", |
| + "id": 123456789, |
| + "renewal_date": "2020-04-29 17:15:19", |
| + "status": "ACT" |
| + }, |
| + "desc": "" |
| +} |
diff --git a/internal/registrar/openprovider/testdata/taken.json b/internal/registrar/openprovider/testdata/taken.json| new file mode 100644 |
| index 000000000..35e6d919b |
| --- /dev/null |
| +++ b/internal/registrar/openprovider/testdata/taken.json |
| @@ -0,0 +1,5 @@ |
| +{ |
| + "code": 311, |
| + "data": "", |
| + "desc": "Domain already registered or reserved" |
| +} |