mirror of
				https://github.com/gravitl/netmaker.git
				synced 2025-10-31 12:16:29 +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 | package controller | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" |  | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/gravitl/netmaker/models" | 	"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) { | func TestValidateDNSUpdate(t *testing.T) { | ||||||
| 	entry := models.DNSEntry{"10.0.0.2", "myhost", "skynet"} | 	entry := models.DNSEntry{"10.0.0.2", "myhost", "skynet"} | ||||||
| 	_, _ = DeleteDNS("mynode", "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() | 	address := servercfg.GetGRPCHost() + ":" + servercfg.GetGRPCPort() | ||||||
|  |  | ||||||
| 	accessstringdec := address + "|" + netID + "|" + accesskey.Value + "|" + privAddr | 	accessstringdec := address + "|" + netID + "|" + accesskey.Value + "|" + privAddr | ||||||
| 	accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec)) | 	accesskey.AccessString = base64.StdEncoding.EncodeToString([]byte(accessstringdec)) | ||||||
| 	//validate accesskey | 	//validate accesskey | ||||||
| 	v := validator.New() | 	v := validator.New() | ||||||
| 	err = v.Struct(accesskey) | 	err := v.Struct(accesskey) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		for _, e := range err.(validator.ValidationErrors) { | 		for _, e := range err.(validator.ValidationErrors) { | ||||||
| 			fmt.Println(e) | 			fmt.Println(e) | ||||||
|   | |||||||
| @@ -223,7 +223,7 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.UpdateNo | |||||||
| 	// Get the node data from the request | 	// Get the node data from the request | ||||||
| 	data := req.GetNode() | 	data := req.GetNode() | ||||||
| 	// Now we have to convert this into a NodeItem type to convert into BSON | 	// Now we have to convert this into a NodeItem type to convert into BSON | ||||||
| 	nodechange := models.Node{ | 	nodechange := models.NodeUpdate{ | ||||||
| 		// ID:       primitive.NilObjectID, | 		// ID:       primitive.NilObjectID, | ||||||
| 		MacAddress:          data.GetMacaddress(), | 		MacAddress:          data.GetMacaddress(), | ||||||
| 		Name:                data.GetName(), | 		Name:                data.GetName(), | ||||||
|   | |||||||
| @@ -2,13 +2,11 @@ package functions | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"path/filepath" | 	"io/ioutil" | ||||||
| 	"log" | 	"log" | ||||||
| 	"os" | 	"os" | ||||||
| 	"io/ioutil" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  |  | ||||||
| func FileExists(f string) bool { | func FileExists(f string) bool { | ||||||
| 	info, err := os.Stat(f) | 	info, err := os.Stat(f) | ||||||
| 	if os.IsNotExist(err) { | 	if os.IsNotExist(err) { | ||||||
| @@ -18,7 +16,12 @@ func FileExists(f string) bool { | |||||||
| } | } | ||||||
|  |  | ||||||
| func SetCorefile(domains string) error { | 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 { | 	if err != nil { | ||||||
| 		return err | 		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
	 Matthew R Kasun
					Matthew R Kasun