mattermost-community-enterp.../channels/app/import_utils_test.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

46 lines
1.3 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package app
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGeneratePassword(t *testing.T) {
mainHelper.Parallel(t)
t.Run("Should be the minimum length or 4, whichever is less", func(t *testing.T) {
password1, err := generatePassword(5)
require.NoError(t, err)
assert.Len(t, password1, 5)
password2, err := generatePassword(10)
require.NoError(t, err)
assert.Len(t, password2, 10)
password3, err := generatePassword(1)
require.NoError(t, err)
assert.Len(t, password3, 4)
})
t.Run("Should contain at least one of symbols, upper case, lower case and numbers", func(t *testing.T) {
password, err := generatePassword(4)
require.NoError(t, err)
require.Len(t, password, 4)
assert.Contains(t, []rune(passwordUpperCaseLetters), []rune(password)[0])
assert.Contains(t, []rune(passwordNumbers), []rune(password)[1])
assert.Contains(t, []rune(passwordLowerCaseLetters), []rune(password)[2])
assert.Contains(t, []rune(passwordSpecialChars), []rune(password)[3])
})
t.Run("Should not fail on concurrent calls", func(t *testing.T) {
for range 10 {
go func() {
_, err := generatePassword(10)
require.NoError(t, err)
}()
}
})
}