| 1 | package authscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/ |
| 2 | |
| 3 | import "testingscip-go gomod github.com/golang/go/src go1.12 testing/" |
| 4 | |
| 5 | func TestParsePlain_Successscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/TestParsePlain_Success().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 6 | data := []byte{'t', 'e', 's', 't', 'i', 0, 't', 'e', 's', 't', 'u', 0, 't', 'e', 's', 't', 'p'} |
| 7 | sasl, err := ParsePlainscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/ParsePlain().(data) |
| 8 | if err != nil { |
| 9 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 10 | } |
| 11 | |
| 12 | if sasl.Identityscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/SaslData#Identity. != "testi" { |
| 13 | t.Fatalfscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatalf().("identity expected %s, actual %s", "testi", sasl.Identityscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/SaslData#Identity.) |
| 14 | } |
| 15 | |
| 16 | if sasl.Passwordscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/SaslData#Password. != "testp" { |
| 17 | t.Fatalfscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatalf().("password expected %s, actual %s", "testi", sasl.Passwordscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/SaslData#Password.) |
| 18 | } |
| 19 | |
| 20 | if sasl.Usernamescip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/SaslData#Username. != "testu" { |
| 21 | t.Fatalfscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatalf().("username expected %s, actual %s", "testi", sasl.Usernamescip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/SaslData#Username.) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | func TestParsePlain_Failed_WrongFormatscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/TestParsePlain_Failed_WrongFormat().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 26 | data := []byte{'t', 'e', 's', 't', 'i', 0, 't', 'e', 's', 't', 'u', 't', 'e', 's', 't', 'p'} |
| 27 | _, err := ParsePlainscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/ParsePlain().(data) |
| 28 | if err == nil { |
| 29 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().("Expected parse error, actual nil") |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func TestCheckPasswordHash_Bcryptscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/TestCheckPasswordHash_Bcrypt().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 34 | password := "tEsTpAsSwOrD123" |
| 35 | hash, err := HashPasswordscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/HashPassword().(password, false) |
| 36 | if err != nil { |
| 37 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 38 | } |
| 39 | |
| 40 | if !CheckPasswordHashscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/CheckPasswordHash().(password, hash, false) { |
| 41 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().("Expected true on check password") |
| 42 | } |
| 43 | |
| 44 | if CheckPasswordHashscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/CheckPasswordHash().("tEsTpAsSwOrD", hash, false) { |
| 45 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().("Expected false on check password") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestCheckPasswordHash_MD5scip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/TestCheckPasswordHash_MD5().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 50 | password := "tEsTpAsSwOrD123" |
| 51 | hash, err := HashPasswordscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/HashPassword().(password, true) |
| 52 | if err != nil { |
| 53 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 54 | } |
| 55 | |
| 56 | if !CheckPasswordHashscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/CheckPasswordHash().(password, hash, true) { |
| 57 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().("Expected true on check password") |
| 58 | } |
| 59 | |
| 60 | if CheckPasswordHashscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/auth`/CheckPasswordHash().("tEsTpAsSwOrD", hash, true) { |
| 61 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().("Expected false on check password") |
| 62 | } |
| 63 | } |