diff --git a/jamf/jamfprointegration/auth_basic.go b/jamf/jamfprointegration/auth_basic.go index 7da3475..558e683 100644 --- a/jamf/jamfprointegration/auth_basic.go +++ b/jamf/jamfprointegration/auth_basic.go @@ -19,7 +19,7 @@ type basicAuth struct { logger logger.Logger // Computed - basicToken string + // basicToken string bearerToken string bearerTokenExpiryTime time.Time } @@ -119,11 +119,7 @@ func (a *basicAuth) tokenExpired() bool { // Returns: // - bool: True if the bearer token is within the buffer period, false otherwise. func (a *basicAuth) tokenInBuffer() bool { - if time.Until(a.bearerTokenExpiryTime) <= a.bufferPeriod { - return true - } - - return false + return time.Until(a.bearerTokenExpiryTime) <= a.bufferPeriod } // tokenEmpty checks if the current bearer token is empty. @@ -132,8 +128,5 @@ func (a *basicAuth) tokenInBuffer() bool { // Returns: // - bool: True if the bearer token is empty, false otherwise. func (a *basicAuth) tokenEmpty() bool { - if a.bearerToken == "" { - return true - } - return false + return a.bearerToken == "" } diff --git a/jamf/jamfprointegration/auth_oauth.go b/jamf/jamfprointegration/auth_oauth.go index 8d43e68..b7608a9 100644 --- a/jamf/jamfprointegration/auth_oauth.go +++ b/jamf/jamfprointegration/auth_oauth.go @@ -58,12 +58,10 @@ func (a *oauth) getNewToken() error { return err } - if resp.StatusCode < 200 && resp.StatusCode > 299 { - return fmt.Errorf("bad request: %v", resp) + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return fmt.Errorf("bad request getting auth token: %v", resp) } - return fmt.Errorf("ERROR CODE: %v", resp.StatusCode) - defer resp.Body.Close() bodyBytes, err := io.ReadAll(resp.Body) @@ -104,18 +102,12 @@ func (a *oauth) getExpiryTime() time.Time { // TODO migrate strings func (a *oauth) tokenExpired() bool { - if a.expiryTime.Before(time.Now()) { - return true - } - return false + return a.expiryTime.Before(time.Now()) } // TODO migrate strings func (a *oauth) tokenInBuffer() bool { - if time.Until(a.expiryTime) <= a.bufferPeriod { - return true - } - return false + return time.Until(a.expiryTime) <= a.bufferPeriod } // TODO migrate strings