diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-08-26 14:03:11 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-10-28 17:02:14 +0100 |
| commit | dd4ce088f22414f503ff810fcfb0c64117b8dfbc (patch) | |
| tree | 712e6e2ab56f5025885be32ff912c53c56a6db83 | |
| parent | b5ea72e09301b9fad3b8e7e2d5b019b82c7f5b12 (diff) | |
Exports: Test AskProfile
| -rw-r--r-- | exports/exports_wrapper.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/exports/exports_wrapper.go b/exports/exports_wrapper.go index 78ce7db..dfd76cf 100644 --- a/exports/exports_wrapper.go +++ b/exports/exports_wrapper.go @@ -47,12 +47,36 @@ func getError(t *testing.T, gerr *C.char) string { return util.GetLanguageMatched(transl.Message, "en") } +// ClonedAskTransition is a clone of the struct types/server.go RequiredAskTransition +// It is cloned here to ensure that when the types API changes, the tests have to be changed as well +type ClonedAskTransition struct { + Cookie int `json:"cookie"` + Data interface{} `json:"data"` +} + //export test_state_callback func test_state_callback(_ C.int, new C.int, data *C.char) int32 { + // OAUTH_STARTED + // We use hardcoded values here instead of constants + // to ensure that a change in the API needs to be changed here too if int(new) == 3 { fakeBrowserAuth(C.GoString(data)) //nolint:errcheck return 1 } + // ASK_PROFILE + if int(new) == 6 { + dataS := C.GoString(data) + var tr ClonedAskTransition + jsonErr := json.Unmarshal([]byte(dataS), &tr) + if jsonErr != nil { + panic(jsonErr) + } + prS := C.CString("employees") + defer FreeString(prS) + CookieReply(C.ulong(tr.Cookie), prS) + return 1 + } + return 0 } @@ -167,6 +191,15 @@ func testServer(t *testing.T) *test.Server { "openvpn", "wireguard" ] + }, + { + "default_gateway": true, + "display_name": "Other", + "profile_id": "other", + "vpn_proto_list": [ + "openvpn", + "wireguard" + ] } ] } @@ -217,6 +250,7 @@ func testServerList(t *testing.T) { ck := CookieNew() defer CookieDelete(ck) + defer CookieCancel(ck) list := fmt.Sprintf("https://%s", serv.Listener.Addr().String()) listS := C.CString(list) |
