Skip to content

Commit

Permalink
SDK-2246:updates for pr checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Oct 13, 2023
1 parent 6566ede commit fba5a14
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion _examples/idv/handlers.session.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func pageFromSessionSpec(c *gin.Context, sessionSpec *create.SessionSpecificatio
return
}
createSessionResult, err = client.CreateSession(sessionSpec)

if err != nil {
c.HTML(
http.StatusInternalServerError,
Expand Down
11 changes: 4 additions & 7 deletions digitalidentity/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func createShareSessionWithErrorResponse(statusCode int, responseBody string) (*
return CreateShareSession(client, &session, "sdkId", "https://apiurl", key)
}

func ExampleGetShareSession() {
func TestGetShareSession(t *testing.T) {
key := test.GetValidKey("../test/test-key.pem")
mockSessionID := "SOME_SESSION_ID"
mockClientSdkId := "SOME_CLIENT_SDK_ID"
Expand All @@ -106,10 +106,7 @@ func ExampleGetShareSession() {
},
}

result, err := GetShareSession(client, mockSessionID, mockClientSdkId, mockApiUrl, key)
if err != nil {
return
}
fmt.Printf("Status code: %s", result.Status)
// Output:Status code: SOME_STATUS
_, err := GetShareSession(client, mockSessionID, mockClientSdkId, mockApiUrl, key)
assert.NilError(t, err)

}
12 changes: 6 additions & 6 deletions digitalidentity/share_session_notification_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ShareSessionNotification struct {
url string
method *string
verifyTLS *bool
headers *map[string][]string
headers map[string][]string
}

// ShareSessionNotificationBuilder builds Share Session Notification
Expand Down Expand Up @@ -37,7 +37,7 @@ func (b *ShareSessionNotificationBuilder) WithVerifyTls(verifyTls bool) *ShareSe

// WithHeaders set headers to Share Session Notification
func (b *ShareSessionNotificationBuilder) WithHeaders(headers map[string][]string) *ShareSessionNotificationBuilder {
b.shareSessionNotification.headers = &headers
b.shareSessionNotification.headers = headers
return b
}

Expand All @@ -49,10 +49,10 @@ func (b *ShareSessionNotificationBuilder) Build() (ShareSessionNotification, err
// MarshalJSON returns the JSON encoding
func (a *ShareSessionNotification) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Url string `json:"url"`
Method *string `json:"method,omitempty"`
VerifyTls *bool `json:"verifyTls,omitempty"`
Headers *map[string][]string `json:"headers,omitempty"`
Url string `json:"url"`
Method *string `json:"method,omitempty"`
VerifyTls *bool `json:"verifyTls,omitempty"`
Headers map[string][]string `json:"headers,omitempty"`
}{
Url: a.url,
Method: a.method,
Expand Down
3 changes: 2 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ sonar.go.coverage.reportPaths = coverage.out
sonar.go.tests.reportPaths = sonar-report.json
sonar.tests = .
sonar.test.inclusions = **/*_test.go
sonar.coverage.exclusions = test/**/*,_examples/**/*,src/digitalidentity/**
sonar.coverage.exclusions = test/**/*,_examples/**/*
sonar.cpd.exclusions = src/digitalidentity/**
10 changes: 5 additions & 5 deletions yotierror/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
)
Expand Down Expand Up @@ -65,8 +65,8 @@ func formatResponseMessage(response *http.Response, httpErrorMessages ...map[int
return defaultMessage
}

body, _ := ioutil.ReadAll(response.Body)
response.Body = ioutil.NopCloser(bytes.NewBuffer(body))
body, _ := io.ReadAll(response.Body)
response.Body = io.NopCloser(bytes.NewBuffer(body))

var errorDO DataObject
jsonError := json.Unmarshal(body, &errorDO)
Expand Down Expand Up @@ -104,8 +104,8 @@ func formatHTTPError(message string, statusCode int, body []byte) string {
func handleHTTPError(response *http.Response, errorMessages ...map[int]string) string {
var body []byte
if response.Body != nil {
body, _ = ioutil.ReadAll(response.Body)
response.Body = ioutil.NopCloser(bytes.NewBuffer(body))
body, _ = io.ReadAll(response.Body)
response.Body = io.NopCloser(bytes.NewBuffer(body))
} else {
body = make([]byte, 0)
}
Expand Down

0 comments on commit fba5a14

Please sign in to comment.