mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-02 21:14:05 +08:00
fixed tests
This commit is contained in:
8
controllers/config/dnsconfig/Corefile
Normal file
8
controllers/config/dnsconfig/Corefile
Normal file
@@ -0,0 +1,8 @@
|
||||
skynet {
|
||||
reload 15s
|
||||
hosts /root/dnsconfig/netmaker.hosts {
|
||||
fallthrough
|
||||
}
|
||||
forward . 8.8.8.8 8.8.4.4
|
||||
log
|
||||
}
|
||||
1
controllers/config/dnsconfig/netmaker.hosts
Normal file
1
controllers/config/dnsconfig/netmaker.hosts
Normal file
@@ -0,0 +1 @@
|
||||
10.0.0.2 myhost.skynet
|
||||
@@ -1,7 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/gravitl/netmaker/models"
|
||||
@@ -66,18 +65,7 @@ func TestDeleteDNS(t *testing.T) {
|
||||
})
|
||||
|
||||
}
|
||||
func TestWriteHosts(t *testing.T) {
|
||||
err := WriteHosts()
|
||||
assert.Nil(t, err)
|
||||
files, err := ioutil.ReadDir("./config")
|
||||
assert.Nil(t, err)
|
||||
for _, file := range files {
|
||||
if file.Name() == "netmaker.hosts" {
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
func TestValidateDNSUpdate(t *testing.T) {
|
||||
entry := models.DNSEntry{"10.0.0.2", "myhost", "skynet"}
|
||||
_, _ = DeleteDNS("mynode", "skynet")
|
||||
|
||||
@@ -604,14 +604,14 @@ func CreateAccessKey(accesskey models.AccessKey, network models.Network) (models
|
||||
}
|
||||
}
|
||||
|
||||
netID := params["networkname"]
|
||||
netID := network.NetID
|
||||
address := servercfg.GetGRPCHost() + ":" + servercfg.GetGRPCPort()
|
||||
|
||||
accessstringdec := address + "|" + netID + "|" + accesskey.Value + "|" + privAddr
|
||||
accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec))
|
||||
//validate accesskey
|
||||
v := validator.New()
|
||||
err = v.Struct(accesskey)
|
||||
err := v.Struct(accesskey)
|
||||
if err != nil {
|
||||
for _, e := range err.(validator.ValidationErrors) {
|
||||
fmt.Println(e)
|
||||
|
||||
@@ -223,7 +223,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo
|
||||
// Get the node data from the request
|
||||
data := req.GetNode()
|
||||
// Now we have to convert this into a NodeItem type to convert into BSON
|
||||
nodechange := models.Node{
|
||||
nodechange := models.NodeUpdate{
|
||||
// ID: primitive.NilObjectID,
|
||||
MacAddress: data.GetMacaddress(),
|
||||
Name: data.GetName(),
|
||||
|
||||
@@ -2,13 +2,11 @@ package functions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
|
||||
func FileExists(f string) bool {
|
||||
info, err := os.Stat(f)
|
||||
if os.IsNotExist(err) {
|
||||
@@ -18,7 +16,12 @@ func FileExists(f string) bool {
|
||||
}
|
||||
|
||||
func SetCorefile(domains string) error {
|
||||
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
//does not work when executing tests
|
||||
//dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
8
test/config/dnsconfig/Corefile
Normal file
8
test/config/dnsconfig/Corefile
Normal file
@@ -0,0 +1,8 @@
|
||||
skynet {
|
||||
reload 15s
|
||||
hosts /root/dnsconfig/netmaker.hosts {
|
||||
fallthrough
|
||||
}
|
||||
forward . 8.8.8.8 8.8.4.4
|
||||
log
|
||||
}
|
||||
1
test/config/dnsconfig/netmaker.hosts
Normal file
1
test/config/dnsconfig/netmaker.hosts
Normal file
@@ -0,0 +1 @@
|
||||
10.71.0.1 mynode.skynet
|
||||
Reference in New Issue
Block a user