code.gitea.io/gitea@v1.19.3/modules/secret/secret_test.go (about)

     1  // Copyright 2019 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package secret
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestEncryptDecrypt(t *testing.T) {
    13  	var hex string
    14  	var str string
    15  
    16  	hex, _ = EncryptSecret("foo", "baz")
    17  	str, _ = DecryptSecret("foo", hex)
    18  	assert.Equal(t, str, "baz")
    19  
    20  	hex, _ = EncryptSecret("bar", "baz")
    21  	str, _ = DecryptSecret("foo", hex)
    22  	assert.NotEqual(t, str, "baz")
    23  }