|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +package arcadego_test |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "errors" |
| 8 | + "os" |
| 9 | + "testing" |
| 10 | + |
| 11 | + "github.com/ArcadeAI/arcade-go" |
| 12 | + "github.com/ArcadeAI/arcade-go/internal/testutil" |
| 13 | + "github.com/ArcadeAI/arcade-go/option" |
| 14 | +) |
| 15 | + |
| 16 | +func TestAdminAuthProviderNewWithOptionalParams(t *testing.T) { |
| 17 | + baseURL := "http://localhost:4010" |
| 18 | + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 19 | + baseURL = envURL |
| 20 | + } |
| 21 | + if !testutil.CheckTestServer(t, baseURL) { |
| 22 | + return |
| 23 | + } |
| 24 | + client := arcadego.NewClient( |
| 25 | + option.WithBaseURL(baseURL), |
| 26 | + option.WithAPIKey("My API Key"), |
| 27 | + ) |
| 28 | + _, err := client.Admin.AuthProviders.New(context.TODO(), arcadego.AdminAuthProviderNewParams{ |
| 29 | + AuthProviderCreateRequest: arcadego.AuthProviderCreateRequestParam{ |
| 30 | + ID: arcadego.F("id"), |
| 31 | + Description: arcadego.F("description"), |
| 32 | + Oauth2: arcadego.F(arcadego.AuthProviderCreateRequestOauth2Param{ |
| 33 | + ClientID: arcadego.F("client_id"), |
| 34 | + AuthorizeRequest: arcadego.F(arcadego.AuthProviderCreateRequestOauth2AuthorizeRequestParam{ |
| 35 | + Endpoint: arcadego.F("endpoint"), |
| 36 | + AuthMethod: arcadego.F("auth_method"), |
| 37 | + Method: arcadego.F("method"), |
| 38 | + Params: arcadego.F(map[string]string{ |
| 39 | + "foo": "string", |
| 40 | + }), |
| 41 | + RequestContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2AuthorizeRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 42 | + ResponseContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2AuthorizeRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 43 | + ResponseMap: arcadego.F(map[string]string{ |
| 44 | + "foo": "string", |
| 45 | + }), |
| 46 | + }), |
| 47 | + ClientSecret: arcadego.F("client_secret"), |
| 48 | + Pkce: arcadego.F(arcadego.AuthProviderCreateRequestOauth2PkceParam{ |
| 49 | + CodeChallengeMethod: arcadego.F("code_challenge_method"), |
| 50 | + Enabled: arcadego.F(true), |
| 51 | + }), |
| 52 | + RefreshRequest: arcadego.F(arcadego.AuthProviderCreateRequestOauth2RefreshRequestParam{ |
| 53 | + Endpoint: arcadego.F("endpoint"), |
| 54 | + AuthMethod: arcadego.F("auth_method"), |
| 55 | + Method: arcadego.F("method"), |
| 56 | + Params: arcadego.F(map[string]string{ |
| 57 | + "foo": "string", |
| 58 | + }), |
| 59 | + RequestContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2RefreshRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 60 | + ResponseContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2RefreshRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 61 | + ResponseMap: arcadego.F(map[string]string{ |
| 62 | + "foo": "string", |
| 63 | + }), |
| 64 | + }), |
| 65 | + ScopeDelimiter: arcadego.F(arcadego.AuthProviderCreateRequestOauth2ScopeDelimiterUnknown0), |
| 66 | + TokenIntrospectionRequest: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenIntrospectionRequestParam{ |
| 67 | + Endpoint: arcadego.F("endpoint"), |
| 68 | + Triggers: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenIntrospectionRequestTriggersParam{ |
| 69 | + OnTokenGrant: arcadego.F(true), |
| 70 | + OnTokenRefresh: arcadego.F(true), |
| 71 | + }), |
| 72 | + AuthMethod: arcadego.F("auth_method"), |
| 73 | + Method: arcadego.F("method"), |
| 74 | + Params: arcadego.F(map[string]string{ |
| 75 | + "foo": "string", |
| 76 | + }), |
| 77 | + RequestContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenIntrospectionRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 78 | + ResponseContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenIntrospectionRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 79 | + ResponseMap: arcadego.F(map[string]string{ |
| 80 | + "foo": "string", |
| 81 | + }), |
| 82 | + }), |
| 83 | + TokenRequest: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenRequestParam{ |
| 84 | + Endpoint: arcadego.F("endpoint"), |
| 85 | + AuthMethod: arcadego.F("auth_method"), |
| 86 | + Method: arcadego.F("method"), |
| 87 | + Params: arcadego.F(map[string]string{ |
| 88 | + "foo": "string", |
| 89 | + }), |
| 90 | + RequestContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 91 | + ResponseContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2TokenRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 92 | + ResponseMap: arcadego.F(map[string]string{ |
| 93 | + "foo": "string", |
| 94 | + }), |
| 95 | + }), |
| 96 | + UserInfoRequest: arcadego.F(arcadego.AuthProviderCreateRequestOauth2UserInfoRequestParam{ |
| 97 | + Endpoint: arcadego.F("endpoint"), |
| 98 | + Triggers: arcadego.F(arcadego.AuthProviderCreateRequestOauth2UserInfoRequestTriggersParam{ |
| 99 | + OnTokenGrant: arcadego.F(true), |
| 100 | + OnTokenRefresh: arcadego.F(true), |
| 101 | + }), |
| 102 | + AuthMethod: arcadego.F("auth_method"), |
| 103 | + Method: arcadego.F("method"), |
| 104 | + Params: arcadego.F(map[string]string{ |
| 105 | + "foo": "string", |
| 106 | + }), |
| 107 | + RequestContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2UserInfoRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 108 | + ResponseContentType: arcadego.F(arcadego.AuthProviderCreateRequestOauth2UserInfoRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 109 | + ResponseMap: arcadego.F(map[string]string{ |
| 110 | + "foo": "string", |
| 111 | + }), |
| 112 | + }), |
| 113 | + }), |
| 114 | + ProviderID: arcadego.F("provider_id"), |
| 115 | + Status: arcadego.F("status"), |
| 116 | + Type: arcadego.F("type"), |
| 117 | + }, |
| 118 | + }) |
| 119 | + if err != nil { |
| 120 | + var apierr *arcadego.Error |
| 121 | + if errors.As(err, &apierr) { |
| 122 | + t.Log(string(apierr.DumpRequest(true))) |
| 123 | + } |
| 124 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +func TestAdminAuthProviderList(t *testing.T) { |
| 129 | + baseURL := "http://localhost:4010" |
| 130 | + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 131 | + baseURL = envURL |
| 132 | + } |
| 133 | + if !testutil.CheckTestServer(t, baseURL) { |
| 134 | + return |
| 135 | + } |
| 136 | + client := arcadego.NewClient( |
| 137 | + option.WithBaseURL(baseURL), |
| 138 | + option.WithAPIKey("My API Key"), |
| 139 | + ) |
| 140 | + _, err := client.Admin.AuthProviders.List(context.TODO()) |
| 141 | + if err != nil { |
| 142 | + var apierr *arcadego.Error |
| 143 | + if errors.As(err, &apierr) { |
| 144 | + t.Log(string(apierr.DumpRequest(true))) |
| 145 | + } |
| 146 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +func TestAdminAuthProviderDelete(t *testing.T) { |
| 151 | + baseURL := "http://localhost:4010" |
| 152 | + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 153 | + baseURL = envURL |
| 154 | + } |
| 155 | + if !testutil.CheckTestServer(t, baseURL) { |
| 156 | + return |
| 157 | + } |
| 158 | + client := arcadego.NewClient( |
| 159 | + option.WithBaseURL(baseURL), |
| 160 | + option.WithAPIKey("My API Key"), |
| 161 | + ) |
| 162 | + _, err := client.Admin.AuthProviders.Delete(context.TODO(), "id") |
| 163 | + if err != nil { |
| 164 | + var apierr *arcadego.Error |
| 165 | + if errors.As(err, &apierr) { |
| 166 | + t.Log(string(apierr.DumpRequest(true))) |
| 167 | + } |
| 168 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 169 | + } |
| 170 | +} |
| 171 | + |
| 172 | +func TestAdminAuthProviderGet(t *testing.T) { |
| 173 | + baseURL := "http://localhost:4010" |
| 174 | + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 175 | + baseURL = envURL |
| 176 | + } |
| 177 | + if !testutil.CheckTestServer(t, baseURL) { |
| 178 | + return |
| 179 | + } |
| 180 | + client := arcadego.NewClient( |
| 181 | + option.WithBaseURL(baseURL), |
| 182 | + option.WithAPIKey("My API Key"), |
| 183 | + ) |
| 184 | + _, err := client.Admin.AuthProviders.Get(context.TODO(), "id") |
| 185 | + if err != nil { |
| 186 | + var apierr *arcadego.Error |
| 187 | + if errors.As(err, &apierr) { |
| 188 | + t.Log(string(apierr.DumpRequest(true))) |
| 189 | + } |
| 190 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 191 | + } |
| 192 | +} |
| 193 | + |
| 194 | +func TestAdminAuthProviderPatchWithOptionalParams(t *testing.T) { |
| 195 | + baseURL := "http://localhost:4010" |
| 196 | + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 197 | + baseURL = envURL |
| 198 | + } |
| 199 | + if !testutil.CheckTestServer(t, baseURL) { |
| 200 | + return |
| 201 | + } |
| 202 | + client := arcadego.NewClient( |
| 203 | + option.WithBaseURL(baseURL), |
| 204 | + option.WithAPIKey("My API Key"), |
| 205 | + ) |
| 206 | + _, err := client.Admin.AuthProviders.Patch( |
| 207 | + context.TODO(), |
| 208 | + "id", |
| 209 | + arcadego.AdminAuthProviderPatchParams{ |
| 210 | + AuthProviderUpdateRequest: arcadego.AuthProviderUpdateRequestParam{ |
| 211 | + ID: arcadego.F("id"), |
| 212 | + Description: arcadego.F("description"), |
| 213 | + Oauth2: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2Param{ |
| 214 | + AuthorizeRequest: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2AuthorizeRequestParam{ |
| 215 | + AuthMethod: arcadego.F("auth_method"), |
| 216 | + Endpoint: arcadego.F("endpoint"), |
| 217 | + Method: arcadego.F("method"), |
| 218 | + Params: arcadego.F(map[string]string{ |
| 219 | + "foo": "string", |
| 220 | + }), |
| 221 | + RequestContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2AuthorizeRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 222 | + ResponseContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2AuthorizeRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 223 | + ResponseMap: arcadego.F(map[string]string{ |
| 224 | + "foo": "string", |
| 225 | + }), |
| 226 | + }), |
| 227 | + ClientID: arcadego.F("client_id"), |
| 228 | + ClientSecret: arcadego.F("client_secret"), |
| 229 | + Pkce: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2PkceParam{ |
| 230 | + CodeChallengeMethod: arcadego.F("code_challenge_method"), |
| 231 | + Enabled: arcadego.F(true), |
| 232 | + }), |
| 233 | + RefreshRequest: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2RefreshRequestParam{ |
| 234 | + AuthMethod: arcadego.F("auth_method"), |
| 235 | + Endpoint: arcadego.F("endpoint"), |
| 236 | + Method: arcadego.F("method"), |
| 237 | + Params: arcadego.F(map[string]string{ |
| 238 | + "foo": "string", |
| 239 | + }), |
| 240 | + RequestContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2RefreshRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 241 | + ResponseContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2RefreshRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 242 | + ResponseMap: arcadego.F(map[string]string{ |
| 243 | + "foo": "string", |
| 244 | + }), |
| 245 | + }), |
| 246 | + ScopeDelimiter: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2ScopeDelimiterUnknown1), |
| 247 | + TokenRequest: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2TokenRequestParam{ |
| 248 | + AuthMethod: arcadego.F("auth_method"), |
| 249 | + Endpoint: arcadego.F("endpoint"), |
| 250 | + Method: arcadego.F("method"), |
| 251 | + Params: arcadego.F(map[string]string{ |
| 252 | + "foo": "string", |
| 253 | + }), |
| 254 | + RequestContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2TokenRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 255 | + ResponseContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2TokenRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 256 | + ResponseMap: arcadego.F(map[string]string{ |
| 257 | + "foo": "string", |
| 258 | + }), |
| 259 | + }), |
| 260 | + UserInfoRequest: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2UserInfoRequestParam{ |
| 261 | + AuthMethod: arcadego.F("auth_method"), |
| 262 | + Endpoint: arcadego.F("endpoint"), |
| 263 | + Method: arcadego.F("method"), |
| 264 | + Params: arcadego.F(map[string]string{ |
| 265 | + "foo": "string", |
| 266 | + }), |
| 267 | + RequestContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2UserInfoRequestRequestContentTypeApplicationXWwwFormUrlencoded), |
| 268 | + ResponseContentType: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2UserInfoRequestResponseContentTypeApplicationXWwwFormUrlencoded), |
| 269 | + ResponseMap: arcadego.F(map[string]string{ |
| 270 | + "foo": "string", |
| 271 | + }), |
| 272 | + Triggers: arcadego.F(arcadego.AuthProviderUpdateRequestOauth2UserInfoRequestTriggersParam{ |
| 273 | + OnTokenGrant: arcadego.F(true), |
| 274 | + OnTokenRefresh: arcadego.F(true), |
| 275 | + }), |
| 276 | + }), |
| 277 | + }), |
| 278 | + ProviderID: arcadego.F("provider_id"), |
| 279 | + Status: arcadego.F("status"), |
| 280 | + Type: arcadego.F("type"), |
| 281 | + }, |
| 282 | + }, |
| 283 | + ) |
| 284 | + if err != nil { |
| 285 | + var apierr *arcadego.Error |
| 286 | + if errors.As(err, &apierr) { |
| 287 | + t.Log(string(apierr.DumpRequest(true))) |
| 288 | + } |
| 289 | + t.Fatalf("err should be nil: %s", err.Error()) |
| 290 | + } |
| 291 | +} |
0 commit comments