IsUAAVersionAtLeast returns true if the UAA version >= minVersion, false otherwise.
(minVersion string)
| 41 | |
| 42 | // IsUAAVersionAtLeast returns true if the UAA version >= minVersion, false otherwise. |
| 43 | func IsUAAVersionAtLeast(minVersion string) bool { |
| 44 | info := fetchAPIVersion() |
| 45 | uaaUrl := fmt.Sprintf("%s/info", info.Links.UAA.Href) |
| 46 | tr := http.DefaultTransport.(*http.Transport).Clone() |
| 47 | tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: SkipSSLValidation()} |
| 48 | req, err := http.NewRequest("GET", uaaUrl, nil) |
| 49 | Expect(err).ToNot(HaveOccurred()) |
| 50 | req.Header.Add("Accept", "application/json") |
| 51 | client := &http.Client{Transport: tr} |
| 52 | resp, err := client.Do(req) |
| 53 | Expect(err).ToNot(HaveOccurred()) |
| 54 | |
| 55 | defer resp.Body.Close() |
| 56 | |
| 57 | if resp.StatusCode == http.StatusOK { |
| 58 | bodyBytes, err2 := io.ReadAll(resp.Body) |
| 59 | Expect(err2).ToNot(HaveOccurred()) |
| 60 | |
| 61 | version := &UAAVersion{} |
| 62 | |
| 63 | err3 := json.Unmarshal(bodyBytes, &version) |
| 64 | Expect(err3).ToNot(HaveOccurred()) |
| 65 | currentUaaVersion := version.Version() |
| 66 | ok, err := versioncheck.IsMinimumAPIVersionMet(currentUaaVersion, minVersion) |
| 67 | Expect(err).ToNot(HaveOccurred()) |
| 68 | return ok |
| 69 | } |
| 70 | Expect(resp.StatusCode).To(Equal(http.StatusOK)) |
| 71 | return false |
| 72 | } |
| 73 | |
| 74 | // SkipIfUAAVersionLessThan is used to skip tests if the UAA version is < the specified version |
| 75 | func SkipIfUAAVersionLessThan(version string) { |
no test coverage detected