-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsecurity_scheme_test.v
More file actions
38 lines (32 loc) · 1.38 KB
/
security_scheme_test.v
File metadata and controls
38 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module openapi
import os
fn test_security_scheme_struct_with_oauth() ? {
content := os.read_file(@VMODROOT + '/testdata/security_scheme.json')?
security_scheme := decode<SecurityScheme>(content)?
oauthflow := security_scheme.flows.implicit
assert security_scheme.security_type == 'oauth2'
assert oauthflow.authorization_url == 'https://example.com/api/oauth/dialog'
assert oauthflow.scopes.len == 2
assert oauthflow.scopes['write:pets'] == 'modify pets in your account'
assert oauthflow.scopes['read:pets'] == 'read your pets'
}
fn test_security_scheme_struct_with_apikey() ? {
content := '{ "type": "apiKey", "name": "api_key", "in": "header" }'
security_scheme := decode<SecurityScheme>(content)?
assert security_scheme.security_type == 'apiKey'
assert security_scheme.name == 'api_key'
assert security_scheme.location == 'header'
}
fn test_security_scheme_struct_with_http() ? {
content := '{ "type": "http", "scheme": "bearer", "bearerFormat": "JWT" }'
security_scheme := decode<SecurityScheme>(content)?
assert security_scheme.security_type == 'http'
assert security_scheme.scheme == 'bearer'
assert security_scheme.bearer_format == 'JWT'
}
fn test_security_scheme_struct_basic() ? {
content := '{ "type": "http", "scheme": "basic" }'
security_scheme := decode<SecurityScheme>(content)?
assert security_scheme.security_type == 'http'
assert security_scheme.scheme == 'basic'
}