Adapt to API using string ID
Previously the API would use integer IDs. This has been silently changed at some point, and now all IDs are strings, even though they seem to still be numeric. From this Github issue https://github.com/go-acme/lego/issues/1685 Njalla devs have confirmed this was an intentional change and all IDs will be strings going forward, meaning we shouln't just have an adapter to keep using our integer IDs, since they might also move away from numeric IDs in the future, and switch to UUID or some other alphanumeric ID.
This commit is contained in:
parent
ef93a5772e
commit
997979f1b8
2 changed files with 17 additions and 17 deletions
|
@ -10,7 +10,7 @@ var ValidPriority = []int{0, 1, 5, 10, 20, 30, 40, 50, 60}
|
|||
|
||||
// Record struct contains data returned by `list-records`
|
||||
type Record struct {
|
||||
ID int `json:"id"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Content string `json:"content"`
|
||||
|
@ -75,7 +75,7 @@ func AddRecord(token string, domain string, record Record) (Record, error) {
|
|||
|
||||
// RemoveRecord removes a given record from a given domain.
|
||||
// If there are no errors it will return `nil`.
|
||||
func RemoveRecord(token string, domain string, id int) error {
|
||||
func RemoveRecord(token string, domain string, id string) error {
|
||||
params := map[string]interface{}{
|
||||
"domain": domain,
|
||||
"id": id,
|
||||
|
|
|
@ -21,28 +21,28 @@ func TestListRecordsExpected(t *testing.T) {
|
|||
"result": {
|
||||
"records": [
|
||||
{
|
||||
"id": 1337,
|
||||
"id": "1337",
|
||||
"name": "_acme-challenge",
|
||||
"type": "TXT",
|
||||
"content": "long-string",
|
||||
"ttl": 10800
|
||||
},
|
||||
{
|
||||
"id": 1338,
|
||||
"id": "1338",
|
||||
"name": "@",
|
||||
"type": "A",
|
||||
"content": "1.2.3.4",
|
||||
"ttl": 3600
|
||||
},
|
||||
{
|
||||
"id": 1339,
|
||||
"id": "1339",
|
||||
"name": "@",
|
||||
"type": "AAAA",
|
||||
"content": "2001:0DB8:0000:0000:0000:8A2E:0370:7334",
|
||||
"ttl": 900
|
||||
},
|
||||
{
|
||||
"id": 1340,
|
||||
"id": "1340",
|
||||
"name": "@",
|
||||
"type": "MX",
|
||||
"content": "mail.protonmail.ch",
|
||||
|
@ -70,28 +70,28 @@ func TestListRecordsExpected(t *testing.T) {
|
|||
|
||||
expected := []Record{
|
||||
{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "_acme-challenge",
|
||||
Type: "TXT",
|
||||
Content: "long-string",
|
||||
TTL: 10800,
|
||||
},
|
||||
{
|
||||
ID: 1338,
|
||||
ID: "1338",
|
||||
Name: "@",
|
||||
Type: "A",
|
||||
Content: "1.2.3.4",
|
||||
TTL: 3600,
|
||||
},
|
||||
{
|
||||
ID: 1339,
|
||||
ID: "1339",
|
||||
Name: "@",
|
||||
Type: "AAAA",
|
||||
Content: "2001:0DB8:0000:0000:0000:8A2E:0370:7334",
|
||||
TTL: 900,
|
||||
},
|
||||
{
|
||||
ID: 1340,
|
||||
ID: "1340",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "mail.protonmail.ch",
|
||||
|
@ -140,7 +140,7 @@ func TestAddRecordExpected(t *testing.T) {
|
|||
testData := `{
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"id": 1337,
|
||||
"id": "1337",
|
||||
"name": "@",
|
||||
"type": "MX",
|
||||
"content": "testing.com",
|
||||
|
@ -173,7 +173,7 @@ func TestAddRecordExpected(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := Record{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "testing.com",
|
||||
|
@ -221,7 +221,7 @@ func TestAddRecordError(t *testing.T) {
|
|||
func TestRemoveRecordExpected(t *testing.T) {
|
||||
token := "test-token"
|
||||
domain := "testing.com"
|
||||
id := 1337
|
||||
id := "1337"
|
||||
Client = &mocks.MockClient{}
|
||||
|
||||
testData := `{
|
||||
|
@ -244,7 +244,7 @@ func TestRemoveRecordExpected(t *testing.T) {
|
|||
func TestRemoveRecordError(t *testing.T) {
|
||||
token := "test-token"
|
||||
domain := "testing.com"
|
||||
id := 1337
|
||||
id := "1337"
|
||||
Client = &mocks.MockClient{}
|
||||
|
||||
testData := `{
|
||||
|
@ -275,7 +275,7 @@ func TestEditRecordExpected(t *testing.T) {
|
|||
testData := `{
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"id": 1337,
|
||||
"id": "1337",
|
||||
"name": "@",
|
||||
"type": "MX",
|
||||
"content": "testing.com",
|
||||
|
@ -294,7 +294,7 @@ func TestEditRecordExpected(t *testing.T) {
|
|||
|
||||
priority := 10
|
||||
editing := Record{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "testing.com",
|
||||
|
@ -329,7 +329,7 @@ func TestEditRecordError(t *testing.T) {
|
|||
|
||||
priority := 10
|
||||
editing := Record{
|
||||
ID: 1337,
|
||||
ID: "1337",
|
||||
Name: "@",
|
||||
Type: "MX",
|
||||
Content: "testing.com",
|
||||
|
|
Loading…
Reference in a new issue