Skip to content
Snippets Groups Projects
Select Git revision
  • 0dd031528e8b3bbf534d1e89d8d34e4b50499f66
  • release default
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • master protected
  • XX-4688/DbEncoding
  • hotfix/update
  • @XX-4682/Files
  • hotfix/XX-4655
  • dev protected
  • project/HavenNotifications
  • XX-4602/SilentMessageType
  • jono/npmTest
  • wasmTest2
  • XX-4461/FileUpload
  • XX-4505/blockuser
  • XX-4441
  • Jakub/Emoji-CI-Test
  • testing/websockets
  • fastReg
  • fast-registration
  • NewHostPool
  • v0.3.22
  • v0.3.21
  • v0.3.20
  • v0.3.18
  • v0.3.17
  • v0.3.16
  • v0.3.15
  • v0.3.14
  • v0.3.13
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • 812b395df518ce096d01d5292596ca26f8fe92d9c4487ddfa515e190a51aa1a1
  • 76ba08e2dfa1798412a265404fa271840b52c035869111fce8e8cdb23a036a5a
41 results

utils.go

Blame
  • authError_test.go 1.58 KiB
    ////////////////////////////////////////////////////////////////////////////////
    // Copyright © 2022 xx foundation                                             //
    //                                                                            //
    // Use of this source code is governed by a license that can be found in the  //
    // LICENSE file.                                                              //
    ////////////////////////////////////////////////////////////////////////////////
    
    package connect
    
    import (
    	"errors"
    	"gitlab.com/xx_network/primitives/id"
    	"strings"
    	"testing"
    )
    
    func TestAuthError(t *testing.T) {
    	expectedAuthErrorStr := "Failed to authenticate id: c29pc29pc29pAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
    	result := AuthError(id.NewIdFromString("soisoisoi", id.Generic, t))
    	if result == nil {
    		t.Error("AuthError did not return an error object")
    	}
    	if result.Error() != expectedAuthErrorStr {
    		t.Errorf("returned error not as expected: Expected: %s, received: %s",
    			expectedAuthErrorStr, result.Error())
    	}
    
    	result = AuthError(nil)
    	if result == nil || !strings.Contains(result.Error(), "due to nil id") {
    		t.Errorf("returned error not as expected: Expected: %s, received: %s",
    			"due to nil id", result.Error())
    	}
    
    }
    
    func TestIsAuthError(t *testing.T) {
    	isAuthError := errors.New("Failed to authenticate id: soisoisoi")
    
    	if !IsAuthError(isAuthError) {
    		t.Errorf("IsAuthError returned that authError is not an authError")
    	}
    
    	notAuthError := errors.New("dont feed the plants")
    
    	if IsAuthError(notAuthError) {
    		t.Errorf("IsAuthError returned that a non authError is an authError")
    	}
    }