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


##########
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:
   [P1] 这两个测试没有任何环境守卫,直接依赖本机已经启动好的 Pixiu/Keycloak。现在在干净环境里跑 `go test 
./auth/saml/test` 会直接因为 `127.0.0.1:8888` 
拒绝连接而失败,我本地已经复现了。样例仓库里的测试如果必须依赖外部服务,至少要用环境变量或 `testing.Short()` 做显式门控,否则普通 `go 
test` 根本跑不过。



-- 
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