@@ -19,6 +19,11 @@ import (
1919 "github.com/NVIDIA/aistore/tools/tassert"
2020)
2121
22+ var (
23+ validIssUrls = []string {"https://localhost:8080" }
24+ invalidIssUrls = []string {"invalid-scheme" }
25+ )
26+
2227func TestConfigTestEnv (t * testing.T ) {
2328 oldConfig := cmn .GCO .Get ()
2429 defer func () {
@@ -83,9 +88,11 @@ func TestAuthConfValidateFailure(t *testing.T) {
8388 desc string
8489 }{
8590 {auth : cmn.AuthConf {Enabled : true , Signature : nil , OIDC : nil }, desc : "no provided validation config" },
86- {auth : cmn.AuthConf {Enabled : true , Signature : & cmn.AuthSignatureConf {Key : "key" , Method : "HS256" }, OIDC : & cmn.OIDCConf {}}, desc : "both configs set" },
8791 {auth : cmn.AuthConf {Enabled : true , Signature : & cmn.AuthSignatureConf {Key : "key" }, OIDC : nil }, desc : "missing method" },
8892 {auth : cmn.AuthConf {Enabled : true , Signature : & cmn.AuthSignatureConf {Key : "key" , Method : "wrong" }, OIDC : nil }, desc : "invalid method" },
93+ {auth : cmn.AuthConf {Enabled : true , Signature : & cmn.AuthSignatureConf {Key : "key" , Method : "HS256" }, OIDC : & cmn.OIDCConf {AllowedIssuers : validIssUrls }}, desc : "both configs set" },
94+ {auth : cmn.AuthConf {Enabled : true , Signature : nil , OIDC : & cmn.OIDCConf {AllowedIssuers : invalidIssUrls }}, desc : "invalid allowed issuer" },
95+ {auth : cmn.AuthConf {Enabled : true , Signature : nil , OIDC : & cmn.OIDCConf {AllowedIssuers : []string {}}}, desc : "missing allowed issuers" },
8996 }
9097 for _ , tt := range tests {
9198 if err := tt .auth .Validate (); err == nil {
@@ -100,11 +107,12 @@ func TestAuthConfValidateSuccess(t *testing.T) {
100107 desc string
101108 }{
102109 {auth : cmn.AuthConf {Enabled : true , Signature : & cmn.AuthSignatureConf {Key : "key" , Method : "HS256" }}, desc : "valid signature" },
110+ {auth : cmn.AuthConf {Enabled : true , Signature : nil , OIDC : & cmn.OIDCConf {AllowedIssuers : validIssUrls }}, desc : "valid OIDC" },
103111 {auth : cmn.AuthConf {Enabled : false , Signature : nil , OIDC : nil }, desc : "not enabled" },
104112 }
105113 for _ , tt := range tests {
106114 if err := tt .auth .Validate (); err != nil {
107- t .Errorf ("AuthConf.Validate() unexpected error [%s] for %#v: %v" , tt .desc , tt .auth , err )
115+ t .Errorf ("AuthConf.Validate() for case [%s] with %#v raised unexpected error : %v" , tt .desc , tt .auth , err )
108116 }
109117 }
110118}
0 commit comments