(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestMethodExprValidate(t *testing.T) { |
| 15 | cases := []struct { |
| 16 | Name string |
| 17 | DSL func() |
| 18 | Error string |
| 19 | }{ |
| 20 | {"valid-security-schemes-extend", testdata.ValidSecuritySchemesExtendDSL, ""}, |
| 21 | {"invalid-security-schemes", testdata.InvalidSecuritySchemesDSL, |
| 22 | `service "InvalidSecuritySchemesService" method "SecureMethod": payload of method "SecureMethod" of service "InvalidSecuritySchemesService" does not define a username attribute, use Username to define one |
| 23 | service "InvalidSecuritySchemesService" method "SecureMethod": payload of method "SecureMethod" of service "InvalidSecuritySchemesService" does not define a password attribute, use Password to define one |
| 24 | service "InvalidSecuritySchemesService" method "SecureMethod": payload of method "SecureMethod" of service "InvalidSecuritySchemesService" does not define a Bearer token attribute, use BearerToken to define one |
| 25 | service "InvalidSecuritySchemesService" method "SecureMethod": payload of method "SecureMethod" of service "InvalidSecuritySchemesService" does not define a JWT attribute, use Token to define one |
| 26 | service "InvalidSecuritySchemesService" method "SecureMethod": security scope "not:found" not found in any of the security schemes. |
| 27 | flow authorization_code: invalid token URL "^example:/token<>": parse "^example:/token<>": first path segment in URL cannot contain colon |
| 28 | flow authorization_code: invalid authorization URL "http://^authorization": parse "http://^authorization": invalid character "^" in host name |
| 29 | flow authorization_code: invalid refresh URL "http://refresh^": parse "http://refresh^": invalid character "^" in host name |
| 30 | service "InvalidSecuritySchemesService" method "InheritedSecureMethod": payload of method "InheritedSecureMethod" of service "InvalidSecuritySchemesService" does not define a OAuth2 access token attribute, use AccessToken to define one |
| 31 | service "InvalidSecuritySchemesService" method "InheritedSecureMethod": payload of method "InheritedSecureMethod" of service "InvalidSecuritySchemesService" does not define an API key attribute, use APIKey to define one |
| 32 | service "InvalidSecuritySchemesService" method "InheritedSecureMethod": security scope "not:found" not found in any of the security schemes. |
| 33 | service "AnotherInvalidSecuritySchemesService" method "Method": payload of method "Method" of service "AnotherInvalidSecuritySchemesService" defines a username attribute, but no basic auth security scheme exist |
| 34 | service "AnotherInvalidSecuritySchemesService" method "Method": payload of method "Method" of service "AnotherInvalidSecuritySchemesService" defines a password attribute, but no basic auth security scheme exist |
| 35 | service "AnotherInvalidSecuritySchemesService" method "Method": payload of method "Method" of service "AnotherInvalidSecuritySchemesService" defines an API key attribute, but no APIKey security scheme exist |
| 36 | service "AnotherInvalidSecuritySchemesService" method "Method": payload of method "Method" of service "AnotherInvalidSecuritySchemesService" defines a Bearer token attribute, but no Bearer security scheme exist |
| 37 | service "AnotherInvalidSecuritySchemesService" method "Method": payload of method "Method" of service "AnotherInvalidSecuritySchemesService" defines a JWT token attribute, but no JWT auth security scheme exist |
| 38 | service "AnotherInvalidSecuritySchemesService" method "Method": payload of method "Method" of service "AnotherInvalidSecuritySchemesService" defines a OAuth2 access token attribute, but no OAuth2 security scheme exist`, |
| 39 | }, |
| 40 | } |
| 41 | for _, tc := range cases { |
| 42 | t.Run(tc.Name, func(t *testing.T) { |
| 43 | if tc.Error == "" { |
| 44 | expr.RunDSL(t, tc.DSL) |
| 45 | } else { |
| 46 | err := expr.RunInvalidDSL(t, tc.DSL) |
| 47 | assert.Equal(t, tc.Error, stripValidationLocations(err.Error())) |
| 48 | } |
| 49 | }) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestMethodExprFinalizeInheritsBearerFormat(t *testing.T) { |
| 54 | cases := []struct { |
nothing calls this directly
no test coverage detected