-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oliver Fish
committed
Oct 21, 2019
1 parent
46aa733
commit b750477
Showing
1 changed file
with
0 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package talon_access_proxy | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
@@ -12,43 +10,6 @@ import ( | |
"go.uber.org/zap" | ||
) | ||
|
||
func TestAPICallWithHMAC(t *testing.T) { | ||
logger, err := zap.NewDevelopment() | ||
require.NoError(t, err) | ||
// from the https://developers.talon.one/docs/ | ||
tap, err := New(Config{ | ||
TalonAPI: "https://demo.talon.one", | ||
Application: map[string]*ApplicationConfig{ | ||
"73": &ApplicationConfig{ | ||
CalculateHMAC: true, | ||
ApplicationKey: "e3b620ed8144f292", | ||
}, | ||
}, | ||
Logger: logger, | ||
}) | ||
require.NoError(t, err) | ||
|
||
server := httptest.NewServer(tap.Handler()) | ||
|
||
defer server.Close() | ||
|
||
var buffer bytes.Buffer | ||
require.NoError(t, json.NewEncoder(&buffer).Encode(map[string]interface{}{ | ||
"attributes": map[string]interface{}{ | ||
"Email": "[email protected]", | ||
}, | ||
})) | ||
|
||
req, err := http.NewRequest("PUT", server.URL+"/v1/customer_profiles/165f239c", &buffer) | ||
require.NoError(t, err) | ||
req.Header.Set("Content-Signature", "signer=73") | ||
req.Header.Set("Content-Type", "application/json") | ||
res, err := server.Client().Do(req) | ||
require.NoError(t, err) | ||
require.Equal(t, http.StatusOK, res.StatusCode) | ||
require.Equal(t, Version, res.Header.Get("X-Tap")) | ||
} | ||
|
||
func BenchmarkTap(b *testing.B) { | ||
server := httptest.NewServer(nil) | ||
defer server.Close() | ||
|