mirror of https://github.com/databricks/cli.git
Limit test server to only accept GET on read endpoints (#2225)
## Changes Now the test server will only match GET queries for these endpoints ## Tests Existing tests.
This commit is contained in:
parent
b4ed235104
commit
a47a058506
|
@ -68,7 +68,7 @@ func StartServer(t *testing.T) *TestServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddHandlers(server *TestServer) {
|
func AddHandlers(server *TestServer) {
|
||||||
server.Handle("/api/2.0/policies/clusters/list", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.0/policies/clusters/list", func(r *http.Request) (any, error) {
|
||||||
return compute.ListPoliciesResponse{
|
return compute.ListPoliciesResponse{
|
||||||
Policies: []compute.Policy{
|
Policies: []compute.Policy{
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ func AddHandlers(server *TestServer) {
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Handle("/api/2.0/instance-pools/list", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.0/instance-pools/list", func(r *http.Request) (any, error) {
|
||||||
return compute.ListInstancePools{
|
return compute.ListInstancePools{
|
||||||
InstancePools: []compute.InstancePoolAndStats{
|
InstancePools: []compute.InstancePoolAndStats{
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ func AddHandlers(server *TestServer) {
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Handle("/api/2.1/clusters/list", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.1/clusters/list", func(r *http.Request) (any, error) {
|
||||||
return compute.ListClustersResponse{
|
return compute.ListClustersResponse{
|
||||||
Clusters: []compute.ClusterDetails{
|
Clusters: []compute.ClusterDetails{
|
||||||
{
|
{
|
||||||
|
@ -109,13 +109,13 @@ func AddHandlers(server *TestServer) {
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Handle("/api/2.0/preview/scim/v2/Me", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.0/preview/scim/v2/Me", func(r *http.Request) (any, error) {
|
||||||
return iam.User{
|
return iam.User{
|
||||||
UserName: "tester@databricks.com",
|
UserName: "tester@databricks.com",
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Handle("/api/2.0/workspace/get-status", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.0/workspace/get-status", func(r *http.Request) (any, error) {
|
||||||
return workspace.ObjectInfo{
|
return workspace.ObjectInfo{
|
||||||
ObjectId: 1001,
|
ObjectId: 1001,
|
||||||
ObjectType: "DIRECTORY",
|
ObjectType: "DIRECTORY",
|
||||||
|
@ -124,13 +124,13 @@ func AddHandlers(server *TestServer) {
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Handle("/api/2.1/unity-catalog/current-metastore-assignment", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.1/unity-catalog/current-metastore-assignment", func(r *http.Request) (any, error) {
|
||||||
return catalog.MetastoreAssignment{
|
return catalog.MetastoreAssignment{
|
||||||
DefaultCatalogName: "main",
|
DefaultCatalogName: "main",
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
server.Handle("/api/2.0/permissions/directories/1001", func(r *http.Request) (any, error) {
|
server.Handle("GET /api/2.0/permissions/directories/1001", func(r *http.Request) (any, error) {
|
||||||
return workspace.WorkspaceObjectPermissions{
|
return workspace.WorkspaceObjectPermissions{
|
||||||
ObjectId: "1001",
|
ObjectId: "1001",
|
||||||
ObjectType: "DIRECTORY",
|
ObjectType: "DIRECTORY",
|
||||||
|
|
Loading…
Reference in New Issue