altera soa-edit-api para INCEPTION-INCREMENT
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const soaEditAPIIncrease = "INCREASE"
|
const soaEditAPIInceptionIncrement = "INCEPTION-INCREMENT"
|
||||||
|
|
||||||
type HTTPClient interface {
|
type HTTPClient interface {
|
||||||
Do(*http.Request) (*http.Response, error)
|
Do(*http.Request) (*http.Response, error)
|
||||||
@@ -97,7 +97,7 @@ func (c *Client) ListZones(ctx context.Context) ([]Zone, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateZone(ctx context.Context, zone Zone) (Zone, error) {
|
func (c *Client) CreateZone(ctx context.Context, zone Zone) (Zone, error) {
|
||||||
zone.SOAEditAPI = soaEditAPIIncrease
|
zone.SOAEditAPI = soaEditAPIInceptionIncrement
|
||||||
var created Zone
|
var created Zone
|
||||||
if err := c.do(ctx, http.MethodPost, c.path("/zones"), zone, &created); err != nil {
|
if err := c.do(ctx, http.MethodPost, c.path("/zones"), zone, &created); err != nil {
|
||||||
return Zone{}, err
|
return Zone{}, err
|
||||||
@@ -139,7 +139,7 @@ func (c *Client) EnsureAllZonesSOAEditAPI(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SetZoneSOAEditAPI(ctx context.Context, zoneID string) error {
|
func (c *Client) SetZoneSOAEditAPI(ctx context.Context, zoneID string) error {
|
||||||
body := Zone{SOAEditAPI: soaEditAPIIncrease}
|
body := Zone{SOAEditAPI: soaEditAPIInceptionIncrement}
|
||||||
return c.do(ctx, http.MethodPut, c.path("/zones/"+url.PathEscape(zoneID)), body, nil)
|
return c.do(ctx, http.MethodPut, c.path("/zones/"+url.PathEscape(zoneID)), body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ func TestCreateZonePostsZone(t *testing.T) {
|
|||||||
if payload.Name != "example.org." || payload.Kind != "Native" {
|
if payload.Name != "example.org." || payload.Kind != "Native" {
|
||||||
t.Fatalf("unexpected payload: %#v", payload)
|
t.Fatalf("unexpected payload: %#v", payload)
|
||||||
}
|
}
|
||||||
if payload.SOAEditAPI != soaEditAPIIncrease {
|
if payload.SOAEditAPI != "INCEPTION-INCREMENT" {
|
||||||
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
@@ -252,7 +252,7 @@ func TestCreateZonePostsZone(t *testing.T) {
|
|||||||
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
||||||
t.Fatalf("decode request: %v", err)
|
t.Fatalf("decode request: %v", err)
|
||||||
}
|
}
|
||||||
if payload.SOAEditAPI != soaEditAPIIncrease {
|
if payload.SOAEditAPI != "INCEPTION-INCREMENT" {
|
||||||
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
@@ -285,7 +285,7 @@ func TestEnsureAllZonesSOAEditAPIUpdatesAllZones(t *testing.T) {
|
|||||||
t.Fatalf("unexpected path: %s", r.URL.Path)
|
t.Fatalf("unexpected path: %s", r.URL.Path)
|
||||||
}
|
}
|
||||||
_ = json.NewEncoder(w).Encode([]Zone{
|
_ = json.NewEncoder(w).Encode([]Zone{
|
||||||
{ID: "already.example.org.", Name: "already.example.org.", SOAEditAPI: soaEditAPIIncrease},
|
{ID: "already.example.org.", Name: "already.example.org.", SOAEditAPI: soaEditAPIInceptionIncrement},
|
||||||
{ID: "missing.example.org.", Name: "missing.example.org."},
|
{ID: "missing.example.org.", Name: "missing.example.org."},
|
||||||
{ID: "", Name: "fallback.example.org.", SOAEditAPI: "DEFAULT"},
|
{ID: "", Name: "fallback.example.org.", SOAEditAPI: "DEFAULT"},
|
||||||
})
|
})
|
||||||
@@ -294,7 +294,7 @@ func TestEnsureAllZonesSOAEditAPIUpdatesAllZones(t *testing.T) {
|
|||||||
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
||||||
t.Fatalf("decode request: %v", err)
|
t.Fatalf("decode request: %v", err)
|
||||||
}
|
}
|
||||||
if payload.SOAEditAPI != soaEditAPIIncrease {
|
if payload.SOAEditAPI != "INCEPTION-INCREMENT" {
|
||||||
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
||||||
}
|
}
|
||||||
updated = append(updated, strings.TrimPrefix(r.URL.Path, "/api/v1/servers/localhost/zones/"))
|
updated = append(updated, strings.TrimPrefix(r.URL.Path, "/api/v1/servers/localhost/zones/"))
|
||||||
@@ -331,7 +331,7 @@ func TestSetZoneSOAEditAPIUsesPUT(t *testing.T) {
|
|||||||
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
|
||||||
t.Fatalf("decode request: %v", err)
|
t.Fatalf("decode request: %v", err)
|
||||||
}
|
}
|
||||||
if payload.SOAEditAPI != soaEditAPIIncrease {
|
if payload.SOAEditAPI != "INCEPTION-INCREMENT" {
|
||||||
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
t.Fatalf("unexpected soa_edit_api: %q", payload.SOAEditAPI)
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
|||||||
@@ -151,6 +151,34 @@ func TestAuthCanBeDisabled(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestZoneRecordsPageShowsSOAEditAPI(t *testing.T) {
|
||||||
|
client := &fakeClient{zone: pdns.Zone{
|
||||||
|
Name: "example.org.",
|
||||||
|
SOAEditAPI: "INCEPTION-INCREMENT",
|
||||||
|
RRSets: []pdns.RRSet{{
|
||||||
|
Name: "example.org.",
|
||||||
|
Type: "SOA",
|
||||||
|
TTL: 3600,
|
||||||
|
}},
|
||||||
|
}}
|
||||||
|
srv, err := New(Config{}, client, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("New returned error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/zones/example.org.", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
srv.routes().ServeHTTP(rec, req)
|
||||||
|
|
||||||
|
if rec.Code != http.StatusOK {
|
||||||
|
t.Fatalf("unexpected status: %d", rec.Code)
|
||||||
|
}
|
||||||
|
body := rec.Body.String()
|
||||||
|
if !strings.Contains(body, "SOA-EDIT-API:") || !strings.Contains(body, "INCEPTION-INCREMENT") {
|
||||||
|
t.Fatalf("expected SOA-EDIT-API value in zone records page, got %q", body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestServesEmbeddedTablerAssets(t *testing.T) {
|
func TestServesEmbeddedTablerAssets(t *testing.T) {
|
||||||
srv, err := New(Config{}, &fakeClient{}, nil)
|
srv, err := New(Config{}, &fakeClient{}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="page-pretitle">Zona</div>
|
<div class="page-pretitle">Zona</div>
|
||||||
<h2 class="page-title">{{ .Zone.Name }}</h2>
|
<h2 class="page-title">{{ .Zone.Name }}</h2>
|
||||||
<div class="text-secondary">{{ len .Zone.RRSets }} conjuntos de registros</div>
|
<div class="text-secondary">
|
||||||
|
{{ len .Zone.RRSets }} conjuntos de registros
|
||||||
|
<span class="mx-1">·</span>
|
||||||
|
SOA-EDIT-API: <code>{{ .Zone.SOAEditAPI }}</code>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto ms-auto">
|
<div class="col-auto ms-auto">
|
||||||
<div class="btn-list">
|
<div class="btn-list">
|
||||||
|
|||||||
Reference in New Issue
Block a user