This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contract-tests: Implement consumer of fabric8auth service.
- Loading branch information
Showing
11 changed files
with
404 additions
and
784 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package fabric8auth | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/fabric8-services/fabric8-auth/test/contracts/model" | ||
"github.com/pact-foundation/pact-go/dsl" | ||
) | ||
|
||
// AuthAPITokenKeys defines contract of /api/status endpoint | ||
func AuthAPITokenKeys(t *testing.T, pact *dsl.Pact) { | ||
|
||
log.Printf("Invoking AuthAPITokenKeys now\n") | ||
|
||
// Pass in test case | ||
var test = func() error { | ||
u := fmt.Sprintf("http://localhost:%d/api/token/keys", pact.Server.Port) | ||
req, err := http.NewRequest("GET", u, nil) | ||
|
||
req.Header.Set("Accept", "application/json") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = http.DefaultClient.Do(req) | ||
if err != nil { | ||
return err | ||
} | ||
return err | ||
} | ||
|
||
// Set up our expected interactions. | ||
pact. | ||
AddInteraction(). | ||
Given("Auth service is up and running."). | ||
UponReceiving("A request to get public keys"). | ||
WithRequest(dsl.Request{ | ||
Method: "GET", | ||
Path: dsl.String("/api/token/keys"), | ||
Headers: dsl.MapMatcher{"Accept": dsl.String("application/json")}, | ||
}). | ||
WillRespondWith(dsl.Response{ | ||
Status: 200, | ||
Headers: dsl.MapMatcher{"Content-Type": dsl.String("application/vnd.publickeys+json")}, | ||
Body: dsl.Match(model.TokenKeys{}), | ||
}) | ||
|
||
// Verify | ||
if err := pact.Verify(test); err != nil { | ||
log.Fatalf("Error on Verify: %v", err) | ||
} | ||
} |
Oops, something went wrong.