go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/certutil/join_pems_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package certutil
     9  
    10  import (
    11  	"os"
    12  	"strings"
    13  	"testing"
    14  
    15  	. "go.charczuk.com/sdk/assert"
    16  )
    17  
    18  func Test_JoinPEMs(t *testing.T) {
    19  	ca, err := os.ReadFile("testdata/ca.cert.pem")
    20  	ItsNil(t, err)
    21  
    22  	serverPartial, err := os.ReadFile("testdata/server.partial.cert.pem")
    23  	ItsNil(t, err)
    24  
    25  	serverFull, err := os.ReadFile("testdata/server.cert.pem")
    26  	ItsNil(t, err)
    27  
    28  	serverJoined := JoinPEMs(string(serverPartial), " ", string(ca))
    29  
    30  	ItsEqual(t, strings.TrimSpace(string(serverFull)), strings.TrimSpace(serverJoined))
    31  }