Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrek-janus committed Jun 18, 2024
1 parent b4c49f8 commit 68383f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions internal/cac/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestClient(t *testing.T) {
_, err := client.InitClient(&client.Configuration{
Config: acpclient.Config{
IssuerURL: issuer,
TenantID: "postmance",
ClientID: "fb346c287c4d4e378cbae39aa0c3fe52",
ClientSecret: "-T1siRsUvmE58hB-2I_fWQZW1lLpk_gK76ZziR8Y9QY",
},
Expand All @@ -32,6 +33,7 @@ func TestClient(t *testing.T) {
_, err := client.InitClient(&client.Configuration{
Config: acpclient.Config{
IssuerURL: issuer,
TenantID: "postmance",
ClientID: "fb346c287c4d4e378cbae39aa0c3fe52",
ClientSecret: "-T1siRsUvmE58hB-2I_fWQZW1lLpk_gK76ZziR8Y9QY",
},
Expand All @@ -47,6 +49,7 @@ func TestClient(t *testing.T) {
c, err := client.InitClient(&client.Configuration{
Config: acpclient.Config{
IssuerURL: issuer,
TenantID: "postmance",
ClientID: "fb346c287c4d4e378cbae39aa0c3fe52",
ClientSecret: "invalid_secret",
},
Expand All @@ -61,12 +64,13 @@ func TestClient(t *testing.T) {

t.Run("client pull configuration without filters", func(t *testing.T) {
testServer := CreateMockServer(t)
issuer, _ := url.Parse(fmt.Sprintf("%s/demo/system", testServer.URL))
issuer, _ := url.Parse(fmt.Sprintf("%s/postmance/system", testServer.URL))

c, err := client.InitClient(&client.Configuration{
Insecure: true,
Config: acpclient.Config{
IssuerURL: issuer,
TenantID: "postmance",
ClientID: "fb346c287c4d4e378cbae39aa0c3fe52",
ClientSecret: "valid_secret",
},
Expand All @@ -88,12 +92,13 @@ func TestClient(t *testing.T) {

t.Run("client pull configuration and filter", func(t *testing.T) {
testServer := CreateMockServer(t)
issuer, _ := url.Parse(fmt.Sprintf("%s/demo/system", testServer.URL))
issuer, _ := url.Parse(fmt.Sprintf("%s/postmance/system", testServer.URL))

c, err := client.InitClient(&client.Configuration{
Insecure: true,
Config: acpclient.Config{
IssuerURL: issuer,
TenantID: "postmance",
ClientID: "fb346c287c4d4e378cbae39aa0c3fe52",
ClientSecret: "valid_secret",
},
Expand All @@ -115,12 +120,13 @@ func TestClient(t *testing.T) {

t.Run("client pull tenant configuration", func(t *testing.T) {
testServer := CreateMockServer(t)
issuer, _ := url.Parse(fmt.Sprintf("%s/demo/system", testServer.URL))
issuer, _ := url.Parse(fmt.Sprintf("%s/postmance/system", testServer.URL))

c, err := client.InitClient(&client.Configuration{
Insecure: true,
Config: acpclient.Config{
IssuerURL: issuer,
TenantID: "postmance",
ClientID: "fb346c287c4d4e378cbae39aa0c3fe52",
ClientSecret: "valid_secret",
},
Expand Down
6 changes: 3 additions & 3 deletions internal/cac/client/mock_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func CreateMockServer(t *testing.T) *httptest.Server {
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {

if req.URL.Path == "/demo/system/.well-known/openid-configuration" {
if req.URL.Path == "/postmance/system/.well-known/openid-configuration" {
js := []byte(`{
"issuer": "https://demo.eu.authz.cloudentity.io/demo/system",
"authorization_endpoint": "https://postmance.eu.authz.cloudentity.io/demo/system/oauth2/auth",
Expand All @@ -27,7 +27,7 @@ func CreateMockServer(t *testing.T) *httptest.Server {
return
}

if req.URL.Path == "/demo/system/oauth2/token" {
if req.URL.Path == "/postmance/system/oauth2/token" {
js := []byte(`{
"token_type": "Bearer",
"scope": "openid",
Expand All @@ -42,7 +42,7 @@ func CreateMockServer(t *testing.T) *httptest.Server {
return
}

if req.URL.Path == "/api/hub/demo//promote/config" {
if req.URL.Path == "/api/hub/postmance/promote/config" {
res.Header().Set("Content-Type", "application/json")
res.WriteHeader(http.StatusOK)
js, err := json.Marshal(models.TreeTenant{
Expand Down

0 comments on commit 68383f8

Please sign in to comment.