...

Source file src/github.com/NCR-Corporation/ncr-bsp-hmac/go/sign/access_key_signer_test.go

Documentation: github.com/NCR-Corporation/ncr-bsp-hmac/go/sign

     1  package sign
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"net/http"
     7  	"strings"
     8  	"testing"
     9  	"time"
    10  )
    11  
    12  func TestAccessKeyHTTPSigner_Sign(t *testing.T) {
    13  	url := "https://gateway-staging.ncrcloud.com/site/sites/find-nearby/88.05,46.25?radius=10000"
    14  	req, _ := http.NewRequest("GET", url, strings.NewReader(""))
    15  	req.Header.Add("Date", time.Now().UTC().Format(http.TimeFormat))
    16  	req.Header.Add("nep-organization", "")
    17  	req.Header.Add("Content-Type", "application/json")
    18  
    19  	// Replace the empty string with your shared key
    20  	sharedKey := ""
    21  	// Replace the empty string with your secret key
    22  	secretKey := ""
    23  	s, _ := NewAccessKeyHTTPSigner(sharedKey, secretKey)
    24  	req, err := s.Sign(req)
    25  	if err != nil {
    26  		t.Fatal(err)
    27  	}
    28  
    29  	res, err := http.DefaultClient.Do(req)
    30  	if err != nil {
    31  		t.Fatal(err)
    32  	}
    33  	defer res.Body.Close()
    34  	b, err := ioutil.ReadAll(res.Body)
    35  	if err != nil {
    36  		t.Fatal(err)
    37  	}
    38  	fmt.Printf("%s\n", b)
    39  }
    40  

View as plain text