diff --git a/iis/iis.go b/iis/iis.go index 8f00cf0..1ae87c5 100644 --- a/iis/iis.go +++ b/iis/iis.go @@ -549,15 +549,10 @@ func applySiteBindings(siteName string, bindings []iisBinding) error { } for cIndex, currentBinding := range currentBindings { - - if binding.IPAddress == "" { - binding.IPAddress = "*" - } if currentBinding.Type == binding.Type && currentBinding.IPAddress == binding.IPAddress && currentBinding.Port == binding.Port && currentBinding.HostName == binding.HostName { exists = true currentBindings[cIndex] = currentBindings[len(currentBindings)-1] currentBindings = currentBindings[:len(currentBindings)-1] - break } } @@ -786,13 +781,13 @@ func getApplication(siteName string, path string, allConfigs bool) (*appCmdApp, args = append(args, "/config:*") } - if result, err := executeAppCmd(args...); err != nil { + result, err := executeAppCmd(args...) + if err != nil { return nil, fmt.Errorf("Failed to get Application: %v", err) } else if len(result.Apps) == 0 { return nil, nil - } else { - return &result.Apps[0], nil } + return &result.Apps[0], nil } // Returns a valid VirtualDir name for IIS/appcmd to ingest @@ -832,19 +827,18 @@ func doesVDirExist(appName string, path string) (bool, error) { // Returns a VirtualDir with the given Application Name and path func getVDir(appName string, path string, allConfigs bool) (*appCmdVDir, error) { - args := []string{"list", "vdir", appName + path} if allConfigs { args = append(args, "/config:*") } - if result, err := executeAppCmd(args...); err != nil { + result, err := executeAppCmd(args...) + if err != nil { return nil, fmt.Errorf("Failed to get Virtual Directory: %v", err) } else if len(result.VDirs) == 0 { return nil, nil - } else { - return &result.VDirs[0], nil } + return &result.VDirs[0], nil } // Sets a VirtualDir with the given Application Name and path to the provided physical path diff --git a/iis/iis_test.go b/iis/iis_test.go index d2ecc84..e461d18 100644 --- a/iis/iis_test.go +++ b/iis/iis_test.go @@ -373,7 +373,6 @@ func TestWebsite(t *testing.T) { } else if len(processIDs) > 0 { for _, processID := range processIDs { cmd := exec.Command(`C:\Windows\System32\taskkill.exe`, "/PID", processID, "/F") - if err := cmd.Run(); err != nil { t.Fatal(err) } @@ -475,6 +474,9 @@ func TestWebsiteWithConfig(t *testing.T) { } parentDir := filepath.Dir(wd) + // Set default for appPool's identity here to prevent GHA-Hosted-CI from corrupting applicationHost.config due ot unknown user at time of running + websiteConfig.AppPoolIdentity = iisAppPoolIdentity{} + websiteConfig.AppPoolConfigPath = filepath.Join(parentDir, "test", "testapppool.xml") websiteConfig.SiteConfigPath = filepath.Join(parentDir, "test", "testsite.xml") @@ -489,7 +491,7 @@ func TestWebsiteWithConfig(t *testing.T) { if appPool, err := getAppPool(guid, true); err != nil { t.Fatal("Failed to get Site info!") } else { - assert.Equal(websiteConfig.AppPoolIdentity.Identity, appPool.Add.ProcessModel.IdentityType, "AppPool Identity Type doesn't match!") + assert.Equal("ApplicationPoolIdentity", appPool.Add.ProcessModel.IdentityType, "AppPool Identity Type doesn't match!") assert.Equal(websiteConfig.AppPoolIdentity.Username, appPool.Add.ProcessModel.Username, "AppPool Identity Username doesn't match!") assert.Equal(websiteConfig.AppPoolIdentity.Password, appPool.Add.ProcessModel.Password, "AppPool Identity Password doesn't match!")