@@ -2931,51 +2931,43 @@ func (c *issue53Conn) SetWriteDeadline(t time.Time) error { return nil }
2931
2931
// golang.org/issue/12895
2932
2932
func TestConfigureServer (t * testing.T ) {
2933
2933
tests := []struct {
2934
- name string
2935
- in http. Server
2936
- wantErr string
2934
+ name string
2935
+ tlsConfig * tls. Config
2936
+ wantErr string
2937
2937
}{
2938
2938
{
2939
2939
name : "empty server" ,
2940
- in : http.Server {},
2941
2940
},
2942
2941
{
2943
2942
name : "just the required cipher suite" ,
2944
- in : http.Server {
2945
- TLSConfig : & tls.Config {
2946
- CipherSuites : []uint16 {tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 },
2947
- },
2943
+ tlsConfig : & tls.Config {
2944
+ CipherSuites : []uint16 {tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 },
2948
2945
},
2949
2946
},
2950
2947
{
2951
2948
name : "missing required cipher suite" ,
2952
- in : http.Server {
2953
- TLSConfig : & tls.Config {
2954
- CipherSuites : []uint16 {tls .TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 },
2955
- },
2949
+ tlsConfig : & tls.Config {
2950
+ CipherSuites : []uint16 {tls .TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 },
2956
2951
},
2957
2952
wantErr : "is missing HTTP/2-required TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ,
2958
2953
},
2959
2954
{
2960
2955
name : "required after bad" ,
2961
- in : http.Server {
2962
- TLSConfig : & tls.Config {
2963
- CipherSuites : []uint16 {tls .TLS_RSA_WITH_RC4_128_SHA , tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 },
2964
- },
2956
+ tlsConfig : & tls.Config {
2957
+ CipherSuites : []uint16 {tls .TLS_RSA_WITH_RC4_128_SHA , tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 },
2965
2958
},
2966
2959
wantErr : "contains an HTTP/2-approved cipher suite (0xc02f), but it comes after" ,
2967
2960
},
2968
2961
{
2969
2962
name : "bad after required" ,
2970
- in : http.Server {
2971
- TLSConfig : & tls.Config {
2972
- CipherSuites : []uint16 {tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 , tls .TLS_RSA_WITH_RC4_128_SHA },
2973
- },
2963
+ tlsConfig : & tls.Config {
2964
+ CipherSuites : []uint16 {tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 , tls .TLS_RSA_WITH_RC4_128_SHA },
2974
2965
},
2975
2966
},
2976
2967
}
2977
2968
for _ , tt := range tests {
2978
- err := ConfigureServer (& tt .in , nil )
2969
+ srv := & http.Server {TLSConfig : tt .tlsConfig }
2970
+ err := ConfigureServer (srv , nil )
2979
2971
if (err != nil ) != (tt .wantErr != "" ) {
2980
2972
if tt .wantErr != "" {
2981
2973
t .Errorf ("%s: success, but want error" , tt .name )
@@ -2986,7 +2978,7 @@ func TestConfigureServer(t *testing.T) {
2986
2978
if err != nil && tt .wantErr != "" && ! strings .Contains (err .Error (), tt .wantErr ) {
2987
2979
t .Errorf ("%s: err = %v; want substring %q" , tt .name , err , tt .wantErr )
2988
2980
}
2989
- if err == nil && ! tt . in .TLSConfig .PreferServerCipherSuites {
2981
+ if err == nil && ! srv .TLSConfig .PreferServerCipherSuites {
2990
2982
t .Errorf ("%s: PreferServerCipherSuite is false; want true" , tt .name )
2991
2983
}
2992
2984
}
0 commit comments