Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
[issue #43]: adds test for missing trailing slash for role name
Browse files Browse the repository at this point in the history
  • Loading branch information
pingles committed Mar 8, 2018
1 parent 591b67f commit 3236622
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions test/functional/metadata_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"testing"
"time"

"github.com/fortytw2/leaktest"
"github.com/uswitch/kiam/pkg/aws/metadata"
"github.com/uswitch/kiam/pkg/aws/sts"
"github.com/uswitch/kiam/pkg/server"
"github.com/uswitch/kiam/pkg/testutil"
"github.com/vmg/backoff"
"io/ioutil"
"net/http"
"testing"
"time"
)

func TestParseAddress(t *testing.T) {
Expand Down Expand Up @@ -134,6 +135,19 @@ func TestReturnRoleForPod(t *testing.T) {
if string(body) != "foo_role" {
t.Error("expected foo_role in body, was", string(body))
}

// The AWS API allows requests to resources both with and without the trailing slash
body, status, err = get(context.Background(), "/latest/meta-data/iam/security-credentials")
if err != nil {
t.Error(err.Error())
}
if status != http.StatusOK {
t.Error("expected 200 response, was", status)
}
if string(body) != "foo_role" {
t.Error("expected foo_role in body, was", string(body))
}

}

func TestReturnErrorWhenNoPodFound(t *testing.T) {
Expand Down

0 comments on commit 3236622

Please sign in to comment.