summaryrefslogtreecommitdiff
path: root/state_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'state_test.go')
-rw-r--r--state_test.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/state_test.go b/state_test.go
index 4320a6d..c6e33e0 100644
--- a/state_test.go
+++ b/state_test.go
@@ -84,15 +84,43 @@ func test_connect_oauth_parameter(t *testing.T, parameters internal.URLParameter
}, false)
_, configErr := state.ConnectInstituteAccess(serverURI)
- if !errors.As(configErr, expectedErr) {
- t.Errorf("error %T = %v, wantErr %T", configErr, configErr, expectedErr)
+ var stateErr *StateConnectError
+ var loginErr *internal.OAuthLoginError
+ var finishErr *internal.OAuthFinishError
+
+ // We go through the chain of errors by unwrapping them one by one
+
+ // First ensure we get a state connect error
+ if !errors.As(configErr, &stateErr) {
+ t.Errorf("error %T = %v, wantErr %T", configErr, configErr, stateErr)
+ }
+
+ // Then ensure we get a login error
+ gotLoginErr := stateErr.Err
+
+ if !errors.As(gotLoginErr, &loginErr) {
+ t.Errorf("error %T = %v, wantErr %T", gotLoginErr, gotLoginErr, loginErr)
+ }
+
+ // Then ensure we get a finish error
+ gotFinishErr := loginErr.Err
+
+ if !errors.As(gotFinishErr, &finishErr) {
+ t.Errorf("error %T = %v, wantErr %T", gotFinishErr, gotFinishErr, finishErr)
+ }
+
+ // Then ensure we get the expected inner error
+ gotExpectedErr := finishErr.Err
+
+ if !errors.As(gotExpectedErr, expectedErr) {
+ t.Errorf("error %T = %v, wantErr %T", gotExpectedErr, gotExpectedErr, expectedErr)
}
}
func Test_connect_oauth_parameters(t *testing.T) {
var (
- failedCallbackParameterError *internal.OAuthFailedCallbackParameterError
- failedCallbackStateMatchError *internal.OAuthFailedCallbackStateMatchError
+ failedCallbackParameterError *internal.OAuthCallbackParameterError
+ failedCallbackStateMatchError *internal.OAuthCallbackStateMatchError
)
tests := []struct {