stmcginnis / gofish

Gofish is a Golang client library for DMTF Redfish and SNIA Swordfish interaction.
BSD 3-Clause "New" or "Revised" License
211 stars 113 forks source link

failed to retrieve some items: [{"link":"/redfish/v1/Systems/system","error":"401: Unauthorized"}] #252

Closed andy-vm closed 1 year ago

andy-vm commented 1 year ago

Hi, I try to get power state but it returns 401, on the browser it works fine w/o this error, pls kindly advise, thanks

config := gofish.ClientConfig{
        Endpoint: host,
        Username: user,
        Password: pass,
        Insecure: true,
    }
    c, err := gofish.Connect(config)
    assert.Equal(t, nil, err, err)
    defer c.Logout()

    service := c.Service

    systems, err := service.Systems()
    assert.Equal(t, nil, err, err)

    for _, system := range systems {
        fmt.Printf("power: %#v\n\n", system.PowerState)
    }
Error Trace:    /github.com/-vm/xxx/pkg/bmc/bmc_test.go:53
            Error:          Not equal: 
                            expected: <nil>(<nil>)
                            actual  : *common.CollectionError(&common.CollectionError{Failures:map[string]error{"/redfish/v1/Systems/system":(*common.Error)(0xc0001c5500)}})
            Test:           TestRedfish
            Messages:       failed to retrieve some items: [{"link":"/redfish/v1/Systems/system","error":"401: Unauthorized"}]
andy-vm commented 1 year ago

works if I set BasicAuth to true, thx