Skylm808 commented on code in PR #125:
URL: 
https://github.com/apache/dubbo-go-pixiu-samples/pull/125#discussion_r2995343650


##########
auth/saml/test/pixiu_test.go:
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package saml
+
+import (
+       "io"
+       "net/http"
+       "os"
+       "path/filepath"
+       "strings"
+       "testing"
+       "time"
+)
+
+func sampleFile(rel string) string {
+       return filepath.Join("..", filepath.FromSlash(rel))
+}
+
+func TestSampleAssetsExist(t *testing.T) {
+       assets := []string{
+               "pixiu/conf.yaml",
+               "server/app/server.go",
+               "docker/docker-compose.yml",
+               "README.md",
+               "README_CN.md",
+               "certs/sp.crt",
+               "certs/sp.key",
+       }
+
+       for _, asset := range assets {
+               if _, err := os.Stat(sampleFile(asset)); err != nil {
+                       t.Fatalf("expected sample asset %s: %v", asset, err)
+               }
+       }
+}
+
+func TestPixiuConfigContainsSAMLFilter(t *testing.T) {
+       data, err := os.ReadFile(sampleFile("pixiu/conf.yaml"))
+       if err != nil {
+               t.Fatalf("read pixiu config: %v", err)
+       }
+
+       content := string(data)
+       required := []string{
+               "dgp.filter.http.auth.saml",
+               "acs_url:",
+               "metadata_url:",
+               "idp_metadata_url:",
+               "allow_idp_initiated: true",
+               "forward_attributes:",
+               "X-User-Email",
+               "X-User-Name",
+               "/app",
+       }
+
+       for _, token := range required {
+               if !strings.Contains(content, token) {
+                       t.Fatalf("expected pixiu config to contain %q", token)
+               }
+       }
+}
+
+func TestMetadataEndpoint(t *testing.T) {

Review Comment:
   已给这两个联调测试加显式门控。默认 go test 只跑静态检查;设置 RUN_SAML_INTEGRATION_TESTS=1 后才会跑依赖 
Pixiu/Keycloak 的联调测试,go test -short 也会跳过。如果服务没启动,测试会 skip,不会在干净环境直接失败



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to