github.com/gdamore/mangos@v1.4.0/test/certs_test.go (about)

     1  // Copyright 2016 The Mangos Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use file except in compliance with the License.
     5  // You may obtain a copy of the license at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES O R CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package test
    16  
    17  import (
    18  	"testing"
    19  
    20  	. "github.com/smartystreets/goconvey/convey"
    21  )
    22  
    23  func TestNewKeys(t *testing.T) {
    24  	Convey("With a new keys", t, func() {
    25  		keys, err := newKeys()
    26  		So(err, ShouldBeNil)
    27  		So(keys, ShouldNotBeNil)
    28  
    29  		Convey("Root signature should check", func() {
    30  			err = keys.root.cert.CheckSignatureFrom(keys.root.cert)
    31  			So(err, ShouldBeNil)
    32  		})
    33  
    34  		Convey("Server signature should check", func() {
    35  			err = keys.server.cert.CheckSignatureFrom(keys.root.cert)
    36  			So(err, ShouldBeNil)
    37  		})
    38  
    39  		Convey("Client signature should check", func() {
    40  			err = keys.client.cert.CheckSignatureFrom(keys.root.cert)
    41  			So(err, ShouldBeNil)
    42  		})
    43  
    44  		Convey("Client cert does not check root", func() {
    45  			err = keys.root.cert.CheckSignatureFrom(keys.client.cert)
    46  			So(err, ShouldNotBeNil)
    47  		})
    48  	})
    49  }
    50  
    51  func TestNewTLSConfig(t *testing.T) {
    52  
    53  	Convey("We can generate a new TLS config", t, func() {
    54  		cfg, err := NewTLSConfig(true)
    55  		So(err, ShouldBeNil)
    56  		So(cfg, ShouldNotBeNil)
    57  	})
    58  }