Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
Exports: Test Let's Connect! disabled features
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijenbergh committed Aug 27, 2024
1 parent ebcc2d2 commit 2244cb7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exports/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ func TestServerList(t *testing.T) {
func TestGetConfig(t *testing.T) {
testGetConfig(t)
}

func TestLetsConnectDiscovery(t *testing.T) {
testLetsConnectDiscovery(t)
}
44 changes: 44 additions & 0 deletions exports/exports_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,47 @@ func testGetConfig(t *testing.T) {
testRenewSession(t)
testCleanup(t)
}

func testLetsConnectDiscovery(t *testing.T) {
// this registers a let's connect! client
mustRegister(t)
defer Deregister()
serv := testServer(t)
defer serv.Close()

ck := CookieNew()
defer CookieDelete(ck)

list := fmt.Sprintf("https://%s", serv.Listener.Addr().String())
listS := C.CString(list)
defer FreeString(listS)

sclient, err := serv.Client()
if err != nil {
t.Fatalf("failed to obtain server client: %v", err)
}

// TODO: can we do this better
http.DefaultTransport = sclient.Client.Transport

// try to add an institute access server
exptErr := fmt.Sprintf("An internal error occurred. The cause of the error is: Adding a non-custom server when the client does not use discovery is not supported, identifier: %s, type: 1.", list)
addErr := getError(t, AddServer(ck, 1, listS, nil))
if addErr != exptErr {
t.Fatalf("failed to add server got a different error: %v, want: %v", addErr, exptErr)
}

_, servErr := DiscoServers(ck, nil)
servErrS := getError(t, servErr)
exptErr = "An internal error occurred. The cause of the error is: Server discovery with this client ID is not supported."
if servErrS != exptErr {
t.Fatalf("discovery servers got a different error: %v, want: %v", servErrS, exptErr)
}

_, orgErr := DiscoOrganizations(ck, nil)
orgErrS := getError(t, orgErr)
exptErr = "An internal error occurred. The cause of the error is: Organization discovery with this client ID is not supported."
if orgErrS != exptErr {
t.Fatalf("discovery organizations got a different error: %v, want: %v", orgErrS, exptErr)
}
}

0 comments on commit 2244cb7

Please sign in to comment.