-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more user tests * Add more user tests * Add linebreaks * Test error conditions * Dont overwrite err * Test error conditions for methods with no output * Actually return errors * Add linebreaks
- Loading branch information
1 parent
39483de
commit 4bbb6ee
Showing
8 changed files
with
311 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"status": "ok", | ||
"code": 200, | ||
"return": 0, | ||
"message": "Success", | ||
"data": [ | ||
"system-xmlrpc-ha-sync" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"status": "ok", | ||
"code": 200, | ||
"return": 0, | ||
"message": "Success", | ||
"data": [ | ||
"admins" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"status": "bad request", | ||
"code": 400, | ||
"return": 5001, | ||
"message": "User does not exist", | ||
"data": [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"status": "ok", | ||
"code": 200, | ||
"return": 0, | ||
"message": "Success", | ||
"data": { | ||
"uid": "2002", | ||
"scope": "user", | ||
"name": "testing123", | ||
"bcrypt-hash": "$2y$10$JDvXIS.ac5yuO.fI5DEtW.K1Xei3USarsVb22Cj6lq1iAwq1jUfQC", | ||
"priv": [], | ||
"descr": "testing123", | ||
"expires": "10/17/2023", | ||
"cert": [], | ||
"authorizedkeys": "", | ||
"ipsecpsk": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"status": "bad request", | ||
"code": 400, | ||
"return": 5001, | ||
"message": "User does not exist", | ||
"data": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package pfsenseapi | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func popSlice[K comparable](slice []K, s int) []K { | ||
return append(slice[:s], slice[s+1:]...) | ||
} | ||
|
||
type resultList struct { | ||
resultsData []string | ||
resultsStatus []int | ||
} | ||
|
||
func (s *resultList) popResult() string { | ||
response := s.resultsData[0] | ||
|
||
s.resultsData = popSlice(s.resultsData, 0) | ||
return response | ||
} | ||
|
||
func (s *resultList) popStatus() int { | ||
response := s.resultsStatus[0] | ||
|
||
s.resultsStatus = popSlice(s.resultsStatus, 0) | ||
return response | ||
} | ||
|
||
func makeResultList(t *testing.T, data string) *resultList { | ||
return &resultList{ | ||
resultsData: []string{ | ||
data, | ||
mustReadFileString(t, "testdata/error.json"), | ||
mustReadFileString(t, "testdata/badjson.json"), | ||
}, | ||
resultsStatus: []int{ | ||
http.StatusOK, | ||
http.StatusBadRequest, | ||
http.StatusOK, | ||
}, | ||
} | ||
} |