diff --git a/config/clients/dotnet/template/README_initializing.mustache b/config/clients/dotnet/template/README_initializing.mustache index 0040ae01..58b44412 100644 --- a/config/clients/dotnet/template/README_initializing.mustache +++ b/config/clients/dotnet/template/README_initializing.mustache @@ -15,7 +15,7 @@ namespace Example { try { var configuration = new ClientConfiguration() { ApiScheme = Environment.GetEnvironmentVariable("FGA_API_SCHEME"), // optional, defaults to "https" - ApiHost = Environment.GetEnvironmentVariable("FGA_API_HOST"), // required, define without the scheme (e.g. api.fga.example instead of https://api.fga.example) + ApiHost = Environment.GetEnvironmentVariable("FGA_API_HOST"), // required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}}) StoreId = Environment.GetEnvironmentVariable("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` AuthorizationModelId = Environment.GetEnvironmentVariable("FGA_AUTHORIZATION_MODEL_ID"), // Optional, can be overridden per request }; @@ -42,7 +42,7 @@ namespace Example { try { var configuration = new ClientConfiguration() { ApiScheme = Environment.GetEnvironmentVariable("FGA_API_SCHEME"), // optional, defaults to "https" - ApiHost = Environment.GetEnvironmentVariable("FGA_API_HOST"), // required, define without the scheme (e.g. api.fga.example instead of https://api.fga.example) + ApiHost = Environment.GetEnvironmentVariable("FGA_API_HOST"), // required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}}) StoreId = Environment.GetEnvironmentVariable("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` AuthorizationModelId = Environment.GetEnvironmentVariable("FGA_AUTHORIZATION_MODEL_ID"), // Optional, can be overridden per request Credentials = new Credentials() { @@ -75,7 +75,7 @@ namespace Example { try { var configuration = new ClientConfiguration() { ApiScheme = Environment.GetEnvironmentVariable("FGA_API_SCHEME"), // optional, defaults to "https" - ApiHost = Environment.GetEnvironmentVariable("FGA_API_HOST"), // required, define without the scheme (e.g. api.fga.example instead of https://api.fga.example) + ApiHost = Environment.GetEnvironmentVariable("FGA_API_HOST"), // required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}}) StoreId = Environment.GetEnvironmentVariable("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` AuthorizationModelId = Environment.GetEnvironmentVariable("FGA_AUTHORIZATION_MODEL_ID"), // Optional, can be overridden per request Credentials = new Credentials() { diff --git a/config/clients/go/template/README_initializing.mustache b/config/clients/go/template/README_initializing.mustache index 402ff830..ceee4606 100644 --- a/config/clients/go/template/README_initializing.mustache +++ b/config/clients/go/template/README_initializing.mustache @@ -12,9 +12,8 @@ import ( func main() { fgaClient, err := NewSdkClient(&ClientConfiguration{ - ApiScheme: os.Getenv("FGA_API_SCHEME"), // optional, defaults to "https" - ApiHost: os.Getenv("FGA_API_HOST"), // required, define without the scheme (e.g. api.fga.example instead of https://api.fga.example) - StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` + ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.{{sampleApiDomain}} + StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` }) if err != nil { @@ -34,9 +33,8 @@ import ( func main() { fgaClient, err := NewSdkClient(&ClientConfiguration{ - ApiScheme: os.Getenv("FGA_API_SCHEME"), // optional, defaults to "https" - ApiHost: os.Getenv("FGA_API_HOST"), // required, define without the scheme (e.g. api.fga.example instead of https://api.fga.example) - StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` + ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.{{sampleApiDomain}} + StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` Credentials: &credentials.Credentials{ Method: credentials.CredentialsMethodApiToken, Config: &credentials.Config{ @@ -63,10 +61,9 @@ import ( func main() { fgaClient, err := NewSdkClient(&ClientConfiguration{ - ApiScheme: os.Getenv("FGA_API_SCHEME"), // optional, defaults to "https" - ApiHost: os.Getenv("FGA_API_HOST"), // required, define without the scheme (e.g. api.fga.example instead of https://api.fga.example) - StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` - AuthorizationModelId: {{packageName}}.PtrString("{{appUpperCaseName}}_AUTHORIZATION_MODEL_ID"), + ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.{{sampleApiDomain}} + StoreId: os.Getenv("FGA_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` + AuthorizationModelId: {{packageName}}.PtrString("{{appUpperCaseName}}_AUTHORIZATION_MODEL_ID"), Credentials: &credentials.Credentials{ Method: credentials.CredentialsMethodClientCredentials, Config: &credentials.Config{ diff --git a/config/clients/go/template/api_client.mustache b/config/clients/go/template/api_client.mustache index c8cdf6fd..421b5e1a 100644 --- a/config/clients/go/template/api_client.mustache +++ b/config/clients/go/template/api_client.mustache @@ -242,23 +242,13 @@ func (c *APIClient) prepareRequest( } // Setup path and query parameters - url, err := url.Parse(path) + uri, err := url.Parse(c.cfg.ApiUrl + path) if err != nil { return nil, err } - // Override request host, if applicable - if c.cfg.ApiHost != "" { - url.Host = c.cfg.ApiHost - } - - // Override request scheme, if applicable - if c.cfg.ApiScheme != "" { - url.Scheme = c.cfg.ApiScheme - } - // Adding Query Param - query := url.Query() + query := uri.Query() for k, v := range queryParams { for _, iv := range v { query.Add(k, iv) @@ -266,13 +256,13 @@ func (c *APIClient) prepareRequest( } // Encode the parameters. - url.RawQuery = query.Encode() + uri.RawQuery = query.Encode() // Generate a new request if body != nil { - localVarRequest, err = http.NewRequest(method, url.String(), body) + localVarRequest, err = http.NewRequest(method, uri.String(), body) } else { - localVarRequest, err = http.NewRequest(method, url.String(), nil) + localVarRequest, err = http.NewRequest(method, uri.String(), nil) } if err != nil { return nil, err diff --git a/config/clients/go/template/api_doc.mustache b/config/clients/go/template/api_doc.mustache index 02b5886f..8601f23f 100644 --- a/config/clients/go/template/api_doc.mustache +++ b/config/clients/go/template/api_doc.mustache @@ -41,8 +41,7 @@ func main() { {{/allParams}} configuration, err := {{packageName}}.NewConfiguration({{packageName}}.Configuration{ - ApiScheme: os.Getenv("{{appUpperCaseName}}_API_SCHEME"), // optional, defaults to "https" - ApiHost: os.Getenv("{{appUpperCaseName}}_API_HOST"), // required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}}) + ApiUrl: os.Getenv("FGA_API_URL"), // required, e.g. https://api.{{sampleApiDomain}} StoreId: os.Getenv("{{appUpperCaseName}}_STORE_ID"), // not needed when calling `CreateStore` or `ListStores` }) diff --git a/config/clients/go/template/api_test.mustache b/config/clients/go/template/api_test.mustache index 9a84e1cd..9ea1a076 100644 --- a/config/clients/go/template/api_test.mustache +++ b/config/clients/go/template/api_test.mustache @@ -104,7 +104,7 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models", configuration.ApiUrl, configuration.StoreId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{ { @@ -236,7 +236,7 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models", configuration.ApiUrl, configuration.StoreId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{ { @@ -276,7 +276,7 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) { if numCalls != 1 { t.Fatalf("Expected call to get access token to be made exactly once, saw: %d", numCalls) } - numCalls = info[fmt.Sprintf("GET %s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId)] + numCalls = info[fmt.Sprintf("GET %s/stores/%s/authorization-models", configuration.ApiUrl, configuration.StoreId)] if numCalls != 1 { t.Fatalf("Expected call to get authorization models to be made exactly once, saw: %d", numCalls) } @@ -300,7 +300,7 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models", configuration.ApiUrl, configuration.StoreId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: []AuthorizationModel{ { @@ -327,7 +327,7 @@ func Test{{appShortName}}ApiConfiguration(t *testing.T) { if numCalls != 0 { t.Fatalf("Unexpected call to get access token made. Expected 0, saw: %d", numCalls) } - numCalls = info[fmt.Sprintf("GET %s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId)] + numCalls = info[fmt.Sprintf("GET %s/stores/%s/authorization-models", configuration.ApiUrl, configuration.StoreId)] if numCalls != 1 { t.Fatalf("Expected call to get authorization models to be made exactly once, saw: %d", numCalls) } @@ -417,7 +417,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -482,7 +482,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -523,7 +523,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath, modelId), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath, modelId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -575,7 +575,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -631,7 +631,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -679,7 +679,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -722,7 +722,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -770,7 +770,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -814,7 +814,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -882,7 +882,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -935,7 +935,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { errObj := ErrorResponse{ Code: "validation_error", @@ -998,7 +998,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { errObj := ErrorResponse{ Code: "auth_failure", @@ -1054,7 +1054,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { errObj := ErrorResponse{ Code: "undefined_endpoint", @@ -1117,7 +1117,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { errObj := ErrorResponse{ Code: "rate_limit_exceeded", @@ -1190,7 +1190,7 @@ func Test{{appShortName}}Api(t *testing.T) { defer httpmock.DeactivateAndReset() firstMock := httpmock.NewStringResponder(429, "") secondMock, _ := httpmock.NewJsonResponder(200, expectedResponse) - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), firstMock.Then(firstMock).Then(firstMock).Then(secondMock), ) updatedConfiguration, err := NewConfiguration(Configuration{ @@ -1250,7 +1250,7 @@ func Test{{appShortName}}Api(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", configuration.ApiUrl, configuration.StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { errObj := ErrorResponse{ Code: "internal_error", diff --git a/config/clients/go/template/client/client.mustache b/config/clients/go/template/client/client.mustache index a950ed66..84c1f1dc 100644 --- a/config/clients/go/template/client/client.mustache +++ b/config/clients/go/template/client/client.mustache @@ -24,8 +24,13 @@ var DEFAULT_MAX_METHOD_PARALLEL_REQS = int32({{clientMaxMethodParallelRequests}} type ClientConfiguration struct { fgaSdk.Configuration - ApiScheme string `json:"api_scheme,omitempty"` + // ApiScheme - defines the scheme for the API: http or https + // Deprecated: use ApiUrl instead of ApiScheme and ApiHost + ApiScheme string `json:"api_scheme,omitempty"` + // ApiHost - defines the host for the API without the scheme e.g. (api.{{sampleApiDomain}}) + // Deprecated: use ApiUrl instead of ApiScheme and ApiHost ApiHost string `json:"api_host,omitempty"` + ApiUrl string `json:"api_url,omitempty"` StoreId string `json:"store_id,omitempty"` AuthorizationModelId *string `json:"authorization_model_id,omitempty"` Credentials *credentials.Credentials `json:"credentials,omitempty"` @@ -40,6 +45,7 @@ func newClientConfiguration(cfg *fgaSdk.Configuration) ClientConfiguration { return ClientConfiguration{ ApiScheme: cfg.ApiScheme, ApiHost: cfg.ApiHost, + ApiUrl: cfg.ApiUrl, StoreId: cfg.StoreId, Credentials: cfg.Credentials, DefaultHeaders: cfg.DefaultHeaders, @@ -59,6 +65,7 @@ func NewSdkClient(cfg *ClientConfiguration) (*{{appShortName}}Client, error) { apiConfiguration, err := fgaSdk.NewConfiguration(fgaSdk.Configuration{ ApiScheme: cfg.ApiScheme, ApiHost: cfg.ApiHost, + ApiUrl: cfg.ApiUrl, StoreId: cfg.StoreId, Credentials: cfg.Credentials, DefaultHeaders: cfg.DefaultHeaders, diff --git a/config/clients/go/template/client/client_test.mustache b/config/clients/go/template/client/client_test.mustache index c11ab937..a0acab40 100644 --- a/config/clients/go/template/client/client_test.mustache +++ b/config/clients/go/template/client/client_test.mustache @@ -23,7 +23,7 @@ type TestDefinition struct { func Test{{appShortName}}Client(t *testing.T) { fgaClient, err := NewSdkClient(&ClientConfiguration{ - ApiHost: "api.fga.example", + ApiUrl: "https://api.{{sampleApiDomain}}", StoreId: "01GXSB9YR785C4FYS3C0RTG7B2", }) if err != nil { @@ -32,16 +32,48 @@ func Test{{appShortName}}Client(t *testing.T) { t.Run("Allow client to have no store ID specified", func(t *testing.T){ _, err := NewSdkClient(&ClientConfiguration{ - ApiHost: "api.fga.example", + ApiHost: "api.{{sampleApiDomain}}", }) if err != nil { - t.Fatalf("Expect no error when store id is not specified but has %v", err) - } + t.Fatalf("Expect no error when store id is not specified but got %v", err) + } + }) + + t.Run("Allow client to have ApiUrl specified", func(t *testing.T) { + _, err := NewSdkClient(&ClientConfiguration{ + ApiUrl: "https://api.{{sampleApiDomain}}", + }) + if err != nil { + t.Fatalf("Expect no error when api url is specified but got %v", err) + } + }) + + t.Run("Ensure that ApiUrl is well formed", func(t *testing.T) { + urls := []string{ + "api.{{sampleApiDomain}}", + "https//api.{{sampleApiDomain}}", + "https://api.{{sampleApiDomain}}:notavalidport", + "https://https://api.{{sampleApiDomain}}", + "notavalidscheme://api.{{sampleApiDomain}}", + } + for _, uri := range urls { + _, err := NewSdkClient(&ClientConfiguration{ + ApiUrl: uri, + }) + if err == nil { + t.Fatalf("Expected an error for invalid uri (%s) but got nil", uri) + } + + expectedErrorString := fmt.Sprintf("Configuration.ApiUrl (%s) does not form a valid uri", uri) + if err.Error() != expectedErrorString { + t.Fatalf("Expected error (%s) but got (%s)", expectedErrorString, err.Error()) + } + } }) t.Run("Allow client to have empty store ID specified", func(t *testing.T){ _, err := NewSdkClient(&ClientConfiguration{ - ApiHost: "api.fga.example", + ApiHost: "api.{{sampleApiDomain}}", StoreId: "", }) if err != nil { @@ -51,7 +83,7 @@ func Test{{appShortName}}Client(t *testing.T) { t.Run("Validate store ID when specified", func(t *testing.T){ _, err := NewSdkClient(&ClientConfiguration{ - ApiHost: "api.fga.example", + ApiHost: "api.{{sampleApiDomain}}", StoreId: "error", }) if err == nil { @@ -61,7 +93,7 @@ func Test{{appShortName}}Client(t *testing.T) { t.Run("Validate auth model ID when specified", func(t *testing.T){ _, err := NewSdkClient(&ClientConfiguration{ - ApiHost: "api.fga.example", + ApiHost: "api.{{sampleApiDomain}}", StoreId: "01GXSB9YR785C4FYS3C0RTG7B2", AuthorizationModelId: {{packageName}}.PtrString("BadAuthID"), }) @@ -72,7 +104,7 @@ func Test{{appShortName}}Client(t *testing.T) { t.Run("Allow auth model ID to be empty when specified", func(t *testing.T){ _, err := NewSdkClient(&ClientConfiguration{ - ApiHost: "api.fga.example", + ApiHost: "api.{{sampleApiDomain}}", StoreId: "01GXSB9YR785C4FYS3C0RTG7B2", AuthorizationModelId: {{packageName}}.PtrString(""), }) @@ -81,6 +113,48 @@ func Test{{appShortName}}Client(t *testing.T) { } }) + t.Run("Allow specifying an ApiUrl with a port and a base path", func(t *testing.T) { + _, err := NewSdkClient(&ClientConfiguration{ + ApiUrl: "https://api.{{sampleApiDomain}}:8080/fga", + StoreId: "01GXSB9YR785C4FYS3C0RTG7B2", + AuthorizationModelId: openfga.PtrString(""), + }) + if err != nil { + t.Fatalf("Expect no error when auth model id is empty but has %v", err) + } + + test := TestDefinition{ + Name: "ListStores", + JsonResponse: `{"stores":[]}`, + ResponseStatus: http.StatusOK, + Method: http.MethodGet, + } + + var expectedResponse openfga.ListStoresResponse + if err := json.Unmarshal([]byte(test.JsonResponse), &expectedResponse); err != nil { + t.Fatalf("%v", err) + } + + httpmock.Activate() + defer httpmock.DeactivateAndReset() + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores", fgaClient.GetConfig().ApiUrl), + func(req *http.Request) (*http.Response, error) { + resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) + if err != nil { + return httpmock.NewStringResponse(http.StatusInternalServerError, ""), nil + } + return resp, nil + }, + ) + + got, err := fgaClient.ListStores(context.Background()).Execute() + if err != nil { + t.Fatalf("%v", err) + } + if len(got.Stores) != 0 { + t.Fatalf("expected stores of length 0, got %v", len(got.Stores)) + } + }) /* Stores */ t.Run("ListStores", func(t *testing.T) { @@ -98,7 +172,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores", fgaClient.GetConfig().ApiUrl), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -149,7 +223,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores", fgaClient.GetConfig().ApiUrl), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -192,7 +266,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -236,7 +310,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores", fgaClient.GetConfig().ApiUrl), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -264,7 +338,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(http.MethodGet, fmt.Sprintf("%s://%s/stores/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, storeId), + httpmock.RegisterResponder(http.MethodGet, fmt.Sprintf("%s/stores/%s", fgaClient.GetConfig().ApiUrl, storeId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -294,7 +368,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, "{}") if err != nil { @@ -331,7 +405,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -416,7 +490,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -464,7 +538,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath, modelId), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath, modelId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -522,7 +596,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -569,7 +643,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -624,7 +698,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -684,7 +758,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -813,7 +887,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -822,7 +896,7 @@ func Test{{appShortName}}Client(t *testing.T) { return resp, nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, authModelId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, authModelId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusOK, ""), nil }, @@ -895,7 +969,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -978,7 +1052,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1067,7 +1141,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1156,7 +1230,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1165,12 +1239,12 @@ func Test{{appShortName}}Client(t *testing.T) { return resp, nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusOK, ""), nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, authModelId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, authModelId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusOK, ""), nil }, @@ -1274,7 +1348,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1283,12 +1357,12 @@ func Test{{appShortName}}Client(t *testing.T) { return resp, nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusUnauthorized, ""), nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, authModelId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, authModelId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusUnauthorized, ""), nil }, @@ -1325,7 +1399,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1392,7 +1466,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1466,7 +1540,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterMatcherResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterMatcherResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), httpmock.BodyContainsString(`"relation":"can_delete"`), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, {{packageName}}.CheckResponse{Allowed: {{packageName}}.PtrBool(false)}) @@ -1476,7 +1550,7 @@ func Test{{appShortName}}Client(t *testing.T) { return resp, nil }, ) - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1485,12 +1559,12 @@ func Test{{appShortName}}Client(t *testing.T) { return resp, nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusOK, ""), nil }, ) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, authModelId), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/stores/%s/authorization-models/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, authModelId), func(req *http.Request) (*http.Response, error) { return httpmock.NewStringResponse(http.StatusOK, ""), nil }, @@ -1592,7 +1666,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath, modelId), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath, modelId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, expectedResponse) if err != nil { @@ -1659,7 +1733,7 @@ func Test{{appShortName}}Client(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s://%s/stores/%s/%s/%s", fgaClient.GetConfig().ApiScheme, fgaClient.GetConfig().ApiHost, fgaClient.GetConfig().StoreId, test.RequestPath, modelId), + httpmock.RegisterResponder(test.Method, fmt.Sprintf("%s/stores/%s/%s/%s", fgaClient.GetConfig().ApiUrl, fgaClient.GetConfig().StoreId, test.RequestPath, modelId), func(req *http.Request) (*http.Response, error) { resp, err := httpmock.NewJsonResponse(test.ResponseStatus, "") if err != nil { diff --git a/config/clients/go/template/configuration.mustache b/config/clients/go/template/configuration.mustache index 3aff4e15..10ac3e8f 100644 --- a/config/clients/go/template/configuration.mustache +++ b/config/clients/go/template/configuration.mustache @@ -22,8 +22,13 @@ type RetryParams struct { // Configuration stores the configuration of the API client type Configuration struct { - ApiScheme string `json:"api_scheme,omitempty"` + // ApiScheme - defines the scheme for the API: http or https + // Deprecated: use ApiUrl instead of ApiScheme and ApiHost + ApiScheme string `json:"api_scheme,omitempty"` + // ApiHost - defines the host for the API without the scheme e.g. (api.{{sampleApiDomain}}) + // Deprecated: use ApiUrl instead of ApiScheme and ApiHost ApiHost string `json:"api_host,omitempty"` + ApiUrl string `json:"api_url,omitempty"` StoreId string `json:"store_id,omitempty"` Credentials *credentials.Credentials `json:"credentials,omitempty"` DefaultHeaders map[string]string `json:"default_headers,omitempty"` @@ -47,9 +52,20 @@ func GetSdkUserAgent() string { // NewConfiguration returns a new Configuration object func NewConfiguration(config Configuration) (*Configuration, error) { + apiUrl := config.ApiUrl + + apiScheme := config.ApiScheme + if apiScheme == "" { + apiScheme = "https" + } + + if apiUrl == "" { + // If api url is not provided, fall back to deprecated config fields + apiUrl = apiScheme + "://" + config.ApiHost + } + cfg := &Configuration{ - ApiScheme: config.ApiScheme, - ApiHost: config.ApiHost, + ApiUrl: apiUrl, StoreId: config.StoreId, Credentials: config.Credentials, DefaultHeaders: config.DefaultHeaders, @@ -58,10 +74,6 @@ func NewConfiguration(config Configuration) (*Configuration, error) { RetryParams: config.RetryParams, } - if cfg.ApiScheme == "" { - cfg.ApiScheme = "https" - } - if cfg.UserAgent == "" { cfg.UserAgent = GetSdkUserAgent() } @@ -86,16 +98,12 @@ func (c *Configuration) AddDefaultHeader(key string, value string) { // ValidateConfig ensures that the given configuration is valid func (c *Configuration) ValidateConfig() error { - if c.ApiHost == "" { - return reportError("Configuration.ApiHost is required") - } - - if c.ApiScheme == "" { - return reportError("Configuration.ApiScheme is required") + if c.ApiUrl == "" { + return reportError("Configuration.ApiUrl is required") } - if !IsWellFormedUri(c.ApiScheme + "://" + c.ApiHost) { - return reportError("Configuration.ApiScheme and Configuration.ApiHost (%s) do not generate a valid uri", c.ApiScheme+"://"+c.ApiHost) + if !IsWellFormedUri(c.ApiUrl) { + return reportError("Configuration.ApiUrl (%s) does not form a valid uri", c.ApiUrl) } if c.Credentials != nil { diff --git a/config/clients/go/template/utils.mustache b/config/clients/go/template/utils.mustache index fa78f108..ceb5b1d9 100644 --- a/config/clients/go/template/utils.mustache +++ b/config/clients/go/template/utils.mustache @@ -322,9 +322,11 @@ func (v *NullableTime) UnmarshalJSON(src []byte) error { func IsWellFormedUri(uriString string) bool { uri, err := url.Parse(uriString) - if (err != nil) || (uri.Scheme != "http" && uri.Scheme != "https") || ((uri.Scheme + "://" + uri.Host) != uriString) { - return false - } + if err != nil || uri.String() != uriString || + uri.Host == "" || uri.Host == "http:" || uri.Host == "https:" || // an indicator of a misconfiguration + (uri.Scheme != "http" && uri.Scheme != "https") { + return false + } return true } diff --git a/config/clients/java/template/config-ClientCredentialsTest.java.mustache b/config/clients/java/template/config-ClientCredentialsTest.java.mustache index a9bb757b..9b053c55 100644 --- a/config/clients/java/template/config-ClientCredentialsTest.java.mustache +++ b/config/clients/java/template/config-ClientCredentialsTest.java.mustache @@ -12,7 +12,7 @@ public class ClientCredentialsTest { private static final List INVALID_IDENTIFIERS = Arrays.asList(null, "", "\t\r\n"); private static final String VALID_CLIENT_ID = "client"; private static final String VALID_CLIENT_SECRET = "secret"; - private static final String VALID_API_TOKEN_ISSUER = "tokenissuer.fga.example"; + private static final String VALID_API_TOKEN_ISSUER = "tokenissuer.{{sampleApiDomain}}"; private static final String VALID_API_AUDIENCE = "audience"; @Test diff --git a/config/clients/js/template/tests/helpers/default-config.ts.mustache b/config/clients/js/template/tests/helpers/default-config.ts.mustache index 18177f5a..db408ee5 100644 --- a/config/clients/js/template/tests/helpers/default-config.ts.mustache +++ b/config/clients/js/template/tests/helpers/default-config.ts.mustache @@ -4,9 +4,9 @@ import { Configuration, UserConfigurationParams } from "../../configuration"; import { CredentialsMethod } from "../../credentials"; export const {{appUpperCaseName}}_STORE_ID = "01H0H015178Y2V4CX10C2KGHF4"; -export const {{appUpperCaseName}}_API_HOST = "api.fga.example"; -export const {{appUpperCaseName}}_API_TOKEN_ISSUER = "tokenissuer.fga.example"; -export const {{appUpperCaseName}}_API_AUDIENCE = "https://api.fga.example/"; +export const {{appUpperCaseName}}_API_HOST = "api.{{sampleApiDomain}}"; +export const {{appUpperCaseName}}_API_TOKEN_ISSUER = "tokenissuer.{{sampleApiDomain}}"; +export const {{appUpperCaseName}}_API_AUDIENCE = "https://api.{{sampleApiDomain}}/"; export const {{appUpperCaseName}}_CLIENT_ID = "01H0H3D8TD07EWAQHXY9BWJG3V"; export const {{appUpperCaseName}}_CLIENT_SECRET = "this-is-very-secret"; export const {{appUpperCaseName}}_API_TOKEN = "fga_abcdef"; diff --git a/config/clients/js/template/tests/index.test.ts.mustache b/config/clients/js/template/tests/index.test.ts.mustache index c3fb8415..62fb5395 100644 --- a/config/clients/js/template/tests/index.test.ts.mustache +++ b/config/clients/js/template/tests/index.test.ts.mustache @@ -59,7 +59,7 @@ describe("{{appTitleCaseName}} SDK", function () { it("should validate host in configuration (adding scheme as part of the host)", () => { expect( - () => new {{appShortName}}Api({ ...baseConfig, apiHost: "https://api.fga.example" }) + () => new {{appShortName}}Api({ ...baseConfig, apiHost: "https://api.{{sampleApiDomain}}" }) ).toThrowError(); }); @@ -71,7 +71,7 @@ describe("{{appTitleCaseName}} SDK", function () { method: CredentialsMethod.ClientCredentials, config: { ...(baseConfig.credentials as any).config, - apiTokenIssuer: "https://tokenissuer.fga.example" + apiTokenIssuer: "https://tokenissuer.{{sampleApiDomain}}" } } as Configuration["credentials"] }) diff --git a/config/clients/python/template/client/test_client.mustache b/config/clients/python/template/client/test_client.mustache index 65549779..03161cb3 100644 --- a/config/clients/python/template/client/test_client.mustache +++ b/config/clients/python/template/client/test_client.mustache @@ -142,7 +142,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.stores, stores) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores', + 'http://api.{{sampleApiDomain}}/stores', headers=ANY, query_params=[('page_size', 1), ('continuation_token', 'continuation_token_example')], @@ -174,7 +174,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.id, '01YCP46JKYM8FJCQ37NMBYHE5X') mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores', + 'http://api.{{sampleApiDomain}}/stores', headers=ANY, query_params=[], post_params=[], @@ -211,7 +211,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.name, "store1") mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X', headers=ANY, query_params=[], _preload_content=ANY, @@ -234,7 +234,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_called_once_with( 'DELETE', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X', headers=ANY, query_params=[], body=None, @@ -321,7 +321,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.continuation_token, "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==") mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', headers=ANY, query_params=[], _preload_content=ANY, @@ -376,7 +376,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_response) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', headers=ANY, query_params=[], post_params=[], @@ -463,7 +463,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.authorization_model, authorization_model) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -547,7 +547,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.authorization_model, authorization_model) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', headers=ANY, query_params=[('page_size', 1)], _preload_content=ANY, @@ -601,7 +601,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, read_changes) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes', headers=ANY, query_params=[('type', 'document'), ('page_size', 1), ('continuation_token', 'abcdefg')], @@ -651,7 +651,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', headers=ANY, query_params=[], post_params=[], @@ -704,7 +704,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', headers=ANY, query_params=[], post_params=[], @@ -982,7 +982,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(mock_request.call_count, 4) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1093,7 +1093,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(mock_request.call_count, 3) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1201,7 +1201,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(mock_request.call_count, 4) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1269,7 +1269,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1407,7 +1407,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1449,7 +1449,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1489,7 +1489,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1533,7 +1533,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1541,7 +1541,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1602,7 +1602,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1610,7 +1610,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1621,7 +1621,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1632,7 +1632,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1701,7 +1701,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1709,7 +1709,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1720,7 +1720,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1731,7 +1731,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1773,7 +1773,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_response) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand', headers=ANY, query_params=[], post_params=[], @@ -1812,7 +1812,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.objects, ['document:abcd1234']) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', headers=ANY, query_params=[], post_params=[], @@ -1859,7 +1859,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.objects, ['document:abcd1234']) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', headers=ANY, query_params=[], post_params=[], @@ -1899,7 +1899,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1907,7 +1907,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1918,7 +1918,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1929,7 +1929,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1965,7 +1965,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -2011,7 +2011,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): )) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -2034,7 +2034,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], @@ -2063,7 +2063,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_client.get_store_id(), "01YCP46JKYM8FJCQ37NMBYHE5Y") mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5Y/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5Y/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], @@ -2092,7 +2092,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_client.get_authorization_model_id(), "01G5JAVJ41T49E9TT3SKVS7X1J") mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], @@ -2122,7 +2122,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X2J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X2J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], diff --git a/config/clients/python/template/client/test_client_sync.mustache b/config/clients/python/template/client/test_client_sync.mustache index 180c6e8d..dff0c3b9 100644 --- a/config/clients/python/template/client/test_client_sync.mustache +++ b/config/clients/python/template/client/test_client_sync.mustache @@ -142,7 +142,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.stores, stores) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores', + 'http://api.{{sampleApiDomain}}/stores', headers=ANY, query_params=[('page_size', 1), ('continuation_token', 'continuation_token_example')], @@ -174,7 +174,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.id, '01YCP46JKYM8FJCQ37NMBYHE5X') mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores', + 'http://api.{{sampleApiDomain}}/stores', headers=ANY, query_params=[], post_params=[], @@ -211,7 +211,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.name, "store1") mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X', headers=ANY, query_params=[], _preload_content=ANY, @@ -234,7 +234,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_called_once_with( 'DELETE', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X', headers=ANY, query_params=[], body=None, @@ -321,7 +321,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.continuation_token, "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==") mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', headers=ANY, query_params=[], _preload_content=ANY, @@ -376,7 +376,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_response) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', headers=ANY, query_params=[], post_params=[], @@ -463,7 +463,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.authorization_model, authorization_model) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -547,7 +547,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.authorization_model, authorization_model) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models', headers=ANY, query_params=[('page_size', 1)], _preload_content=ANY, @@ -601,7 +601,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, read_changes) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/changes', headers=ANY, query_params=[('type', 'document'), ('page_size', 1), ('continuation_token', 'abcdefg')], @@ -651,7 +651,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', headers=ANY, query_params=[], post_params=[], @@ -704,7 +704,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/read', headers=ANY, query_params=[], post_params=[], @@ -982,7 +982,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(mock_request.call_count, 4) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1093,7 +1093,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(mock_request.call_count, 3) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1201,7 +1201,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(mock_request.call_count, 4) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1269,7 +1269,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1407,7 +1407,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -1449,7 +1449,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1489,7 +1489,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1533,7 +1533,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1541,7 +1541,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1602,7 +1602,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1610,7 +1610,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1621,7 +1621,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1632,7 +1632,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1701,7 +1701,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1709,7 +1709,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1720,7 +1720,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1731,7 +1731,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1773,7 +1773,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response, expected_response) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/expand', headers=ANY, query_params=[], post_params=[], @@ -1812,7 +1812,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.objects, ['document:abcd1234']) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', headers=ANY, query_params=[], post_params=[], @@ -1859,7 +1859,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_response.objects, ['document:abcd1234']) mock_request.assert_called_once_with( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/list-objects', headers=ANY, query_params=[], post_params=[], @@ -1899,7 +1899,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): # Make sure the API was called with the right data mock_request.assert_any_call( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -1907,7 +1907,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1918,7 +1918,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1929,7 +1929,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_any_call( 'POST', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/check', headers=ANY, query_params=[], post_params=[], @@ -1965,7 +1965,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/authorization-models/01GXSA8YR785C4FYS3C0RTG7B1', headers=ANY, query_params=[], _preload_content=ANY, @@ -2011,7 +2011,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): )) mock_request.assert_called_once_with( 'GET', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, query_params=[], _preload_content=ANY, @@ -2034,7 +2034,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], @@ -2063,7 +2063,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_client.get_store_id(), "01YCP46JKYM8FJCQ37NMBYHE5Y") mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5Y/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5Y/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], @@ -2092,7 +2092,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): self.assertEqual(api_client.get_authorization_model_id(), "01G5JAVJ41T49E9TT3SKVS7X1J") mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X1J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[], @@ -2122,7 +2122,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): ) mock_request.assert_called_once_with( 'PUT', - 'http://api.fga.example/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X2J', + 'http://api.{{sampleApiDomain}}/stores/01YCP46JKYM8FJCQ37NMBYHE5X/assertions/01G5JAVJ41T49E9TT3SKVS7X2J', headers=ANY, body={"assertions": [{"tuple_key": {"object": "document:2021-budget","relation": "reader","user": "user:anne"},"expectation": True}]}, query_params=[],