This repository has been archived by the owner on May 1, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement dedicated sessions disabled error type
Implement dedicated error and message types for the case of disabled sessions. Add a new integration test case to verify the correct error type returned by session related methods of both the client and the client agent.
- Loading branch information
Showing
19 changed files
with
120 additions
and
19 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
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
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
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
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
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,72 @@ | ||
package test | ||
|
||
import ( | ||
"context" | ||
"reflect" | ||
"testing" | ||
"time" | ||
|
||
wwr "github.com/qbeon/webwire-go" | ||
wwrclt "github.com/qbeon/webwire-go/client" | ||
) | ||
|
||
// TestDisabledSessions verifies the server is connectable, | ||
// and is able to receives requests and signals, create sessions | ||
// and identify clients during request- and signal handling | ||
func TestDisabledSessions(t *testing.T) { | ||
verifyError := func(err error) { | ||
if _, isDisabledErr := err.(wwr.SessionsDisabled); !isDisabledErr { | ||
t.Errorf( | ||
"Expected SessionsDisabled error, got: %s | %s", | ||
reflect.TypeOf(err), | ||
err, | ||
) | ||
} | ||
} | ||
|
||
// Initialize webwire server | ||
_, addr := setupServer( | ||
t, | ||
wwr.ServerOptions{ | ||
SessionsEnabled: false, | ||
Hooks: wwr.Hooks{ | ||
OnRequest: func(ctx context.Context) (wwr.Payload, error) { | ||
// Extract request message and requesting client from the context | ||
msg := ctx.Value(wwr.Msg).(wwr.Message) | ||
|
||
// Try to create a new session and expect an error | ||
createErr := msg.Client.CreateSession(nil) | ||
verifyError(createErr) | ||
|
||
// Try to create a new session and expect an error | ||
closeErr := msg.Client.CloseSession() | ||
verifyError(closeErr) | ||
|
||
return wwr.Payload{}, nil | ||
}, | ||
}, | ||
}, | ||
) | ||
|
||
// Initialize client | ||
client := wwrclt.NewClient( | ||
addr, | ||
wwrclt.Options{ | ||
DefaultRequestTimeout: 2 * time.Second, | ||
}, | ||
) | ||
defer client.Close() | ||
|
||
if err := client.Connect(); err != nil { | ||
t.Fatalf("Couldn't connect: %s", err) | ||
} | ||
|
||
// Send authentication request and await reply | ||
_, err := client.Request("login", wwr.Payload{Data: []byte("testdata")}) | ||
if err != nil { | ||
t.Fatalf("Request failed: %s", err) | ||
} | ||
|
||
sessRestErr := client.RestoreSession([]byte("testkey")) | ||
verifyError(sessRestErr) | ||
} |
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