Skip to content

Commit

Permalink
Address Comments/CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Taylor committed Mar 26, 2021
1 parent ea2626a commit 7640846
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
18 changes: 6 additions & 12 deletions iis/iis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions iis/iis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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")

Expand All @@ -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!")

Expand Down

0 comments on commit 7640846

Please sign in to comment.