From 17242fb079d9172dfc4757acded97700f8e75465 Mon Sep 17 00:00:00 2001 From: graciousgrey Date: Fri, 23 Jun 2023 18:38:54 +0200 Subject: [PATCH] Tests: Add unit tests #3482 --- internal/entity/password_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/entity/password_test.go b/internal/entity/password_test.go index acd05fbf0..c4394a368 100644 --- a/internal/entity/password_test.go +++ b/internal/entity/password_test.go @@ -32,6 +32,20 @@ func TestPassword_SetPassword(t *testing.T) { assert.True(t, p.IsValid("abcd")) assert.False(t, p.IsValid("other")) }) + t.Run("Too long", func(t *testing.T) { + p := NewPassword("urrwaxd19ldtz68x", "hgfttrgkncgdhfkbvuvygvbekdjbrtugbnljbtruhogtgbotuhblenbhoyuhntyyhngytohrpnehotyihniy", false) + + err := p.SetPassword("hgfttrgkncgdhfkbvuvygvbekdjbrtugbnljbtruhogtgbotuhblenbhoyuhntyyhngytohrpnehotyihniy", false) + + assert.Error(t, err) + }) + t.Run("Too short", func(t *testing.T) { + p := NewPassword("urrwaxd19ldtz68x", "", false) + + err := p.SetPassword("", false) + + assert.Error(t, err) + }) t.Run("Hash", func(t *testing.T) { p := NewPassword("urrwaxd19ldtz68x", "$2a$14$qCcNjxupSJV1gjhgdYxz8e9l0e0fTZosX0s0qhMK54IkI9YOyWLt2", true) assert.Len(t, p.Hash, 60)