Skip to content

Commit

Permalink
updated package authentication_utils -> utils
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavmodi committed Oct 2, 2019
1 parent b4622b4 commit d6f717a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions crypto/crypto_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package crypto_test

import (
"github.com/mastercard/oauth1-signer-go/authentication_utils"
"github.com/mastercard/oauth1-signer-go/crypto"
"github.com/mastercard/oauth1-signer-go/utils"
"testing"
)

Expand All @@ -22,7 +22,7 @@ func TestSHA256Hash(t *testing.T) {

func TestRSASignature(t *testing.T) {

privateKey, _ := authentication_utils.LoadSigningKey("../testdata/test_key_container.p12", "Password1")
privateKey, _ := utils.LoadSigningKey("../testdata/test_key_container.p12", "Password1")
var signingData [10]byte
sign, err := crypto.Sign(signingData[:], privateKey)

Expand Down
4 changes: 2 additions & 2 deletions interceptor/http_client_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package interceptor

import (
"github.com/mastercard/oauth1-signer-go"
"github.com/mastercard/oauth1-signer-go/authentication_utils"
"github.com/mastercard/oauth1-signer-go/utils"
"net/http"
)

Expand Down Expand Up @@ -33,7 +33,7 @@ func (h *httpClientInterceptor) RoundTrip(req *http.Request) (*http.Response, er
// filePath: a file path of a RSA private key in PKCS#12 format
// password: a password to read the RSA private key from the given file path
func GetHttpClient(consumerKey, filePath, password string) (*http.Client, error) {
signingKey, e := authentication_utils.LoadSigningKey(filePath, password)
signingKey, e := utils.LoadSigningKey(filePath, password)
if e != nil {
return nil, e
}
Expand Down
4 changes: 2 additions & 2 deletions oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package oauth

import (
"crypto/rsa"
"github.com/mastercard/oauth1-signer-go/authentication_utils"
"github.com/mastercard/oauth1-signer-go/utils"
"net/url"
"reflect"
"testing"
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestSignSignatureBaseString(t *testing.T) {
}

func getTestSigningKey() *rsa.PrivateKey {
signingKey, _ := authentication_utils.LoadSigningKey("testdata/test_key_container.p12", "Password1")
signingKey, _ := utils.LoadSigningKey("testdata/test_key_container.p12", "Password1")
return signingKey
}

Expand Down
4 changes: 2 additions & 2 deletions signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
oauth "github.com/mastercard/oauth1-signer-go"
"github.com/mastercard/oauth1-signer-go/authentication_utils"
"github.com/mastercard/oauth1-signer-go/utils"
"net/http"
"testing"
)
Expand All @@ -14,7 +14,7 @@ const (
)

var (
signingKey, _ = authentication_utils.LoadSigningKey("testdata/test_key_container.p12", "Password1")
signingKey, _ = utils.LoadSigningKey("testdata/test_key_container.p12", "Password1")
jsonData = map[string]string{"foo": "bår"}
jsonValue, _ = json.Marshal(jsonData)
request, _ = http.NewRequest("POST", "https://sandbox.api.mastercard.com/service", bytes.NewBuffer(jsonValue))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package authentication_utils handles loading of signing key.
package authentication_utils
// Package utils handles loading of signing key.
package utils

import (
"crypto/rsa"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package authentication_utils_test
package utils_test

import (
"github.com/mastercard/oauth1-signer-go/authentication_utils"
"github.com/mastercard/oauth1-signer-go/utils"
"testing"
)

func TestLoadSigningKey(t *testing.T) {

path := "../testdata/test_key_container.p12"
password := "Password1"
privateKey, err := authentication_utils.LoadSigningKey(path, password)
privateKey, err := utils.LoadSigningKey(path, password)

if err != nil || privateKey == nil {
t.Errorf("Expected to load RSA privateKey, but thrwon %v", err)
Expand All @@ -18,14 +18,14 @@ func TestLoadSigningKey(t *testing.T) {

func TestLoadSigningKeyInvalidInput(t *testing.T) {

privateKey, err := authentication_utils.LoadSigningKey(
privateKey, err := utils.LoadSigningKey(
"../testdata/invalidFile.p12", "Password1")

if err == nil || privateKey != nil {
t.Errorf("Expected to throw error, but returned privateKey")
}

privateKey, err = authentication_utils.LoadSigningKey(
privateKey, err = utils.LoadSigningKey(
"../testdata/test_key_container.p12", "incorrect_password")

if err == nil || privateKey != nil {
Expand Down

0 comments on commit d6f717a

Please sign in to comment.