mirror of
https://code.forgejo.org/actions/ovh-dns-update
synced 2025-06-08 04:58:21 +02:00
check DNS_TXT
This commit is contained in:
parent
105a5e79af
commit
1e88a41e80
2 changed files with 15 additions and 4 deletions
|
@ -31,3 +31,7 @@ jobs:
|
||||||
ovh-app-key: APP_KEY
|
ovh-app-key: APP_KEY
|
||||||
ovh-app-secret: APP_SECRET
|
ovh-app-secret: APP_SECRET
|
||||||
ovh-consumer-key: CON_KEY
|
ovh-consumer-key: CON_KEY
|
||||||
|
- name: check record update
|
||||||
|
run: |
|
||||||
|
echo ${{ steps.test.outputs.DNS_TXT }}
|
||||||
|
test ${{ steps.test.outputs.DNS_TXT }} = "v1.42"
|
||||||
|
|
15
main_test.go
15
main_test.go
|
@ -4,6 +4,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -59,16 +60,22 @@ func TestRun(t *testing.T) {
|
||||||
t.Error(msg)
|
t.Error(msg)
|
||||||
case "/auth/time":
|
case "/auth/time":
|
||||||
case "/domain/zone/example.org/record/12345":
|
case "/domain/zone/example.org/record/12345":
|
||||||
buf, err := io.ReadAll(r.Body)
|
var body struct {
|
||||||
|
SubDomain string `json:"subDomain"`
|
||||||
|
Target string `json:"target"`
|
||||||
|
}
|
||||||
|
err := json.NewDecoder(r.Body).Decode(&body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintf("could not read request body: %v", err)
|
msg := fmt.Sprintf("could not decode request body: %v", err)
|
||||||
http.Error(w, msg, http.StatusBadRequest)
|
http.Error(w, msg, http.StatusBadRequest)
|
||||||
t.Error(msg)
|
t.Error(msg)
|
||||||
}
|
}
|
||||||
if string(buf) != `{"subDomain":"_release","target":"\"v=1.42\""}` {
|
if body.SubDomain != "_release" {
|
||||||
msg := fmt.Sprintf("unexpected body: %s", string(buf))
|
msg := fmt.Sprintf("unexpected subdomain: %s", body.SubDomain)
|
||||||
http.Error(w, msg, http.StatusBadRequest)
|
http.Error(w, msg, http.StatusBadRequest)
|
||||||
t.Error(msg)
|
t.Error(msg)
|
||||||
|
} else {
|
||||||
|
githubactions.SetOutput("DNS_TXT", body.Target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue