Skip to content

Commit 7ffc0be

Browse files
committed
updated mock management API to handle file permision
1 parent f7255da commit 7ffc0be

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

api/grpc/mpi/v1/files.pb.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/files.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ message FileMeta {
168168
// Last modified time of the file (created time if never modified)
169169
google.protobuf.Timestamp modified_time = 3 [(buf.validate.field).timestamp.lt_now = true];
170170
// The permission set associated with a particular file
171-
string permissions = 4 [(buf.validate.field).string.pattern = "(^$)|(0[0-7]{3})"];
171+
string permissions = 4 [(buf.validate.field).string.pattern = "0[0-7]{3}"];
172172
// The size of the file in bytes
173173
int64 size = 5;
174174
// additional file information

internal/config/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ func (c *Config) IsDomainAllowed(hostname string) bool {
502502
return true
503503
}
504504
} else if hostname == allowed {
505-
// Handle exact matches
506505
return true
507506
}
508507
}

internal/file/file_operator_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ func TestFileOperator_MoveFile_destFileDoesNotExist(t *testing.T) {
107107
}
108108

109109
func TestFileOperator_runHelper(t *testing.T) {
110-
// Common setup for all subtests.
111110
fo := NewFileOperator(&sync.RWMutex{})
112111
ctx := context.Background()
113112
tmpDir := t.TempDir()

test/mock/grpc/mock_management_command_service.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ func NewCommandService(
8484

8585
// Adding a struct to represent the external data source.
8686
type ExternalDataSource struct {
87-
FilePath string `json:"filePath"`
88-
Location string `json:"location"`
87+
FilePath string `json:"filePath"`
88+
Location string `json:"location"`
89+
Permissions string `json:"permissions"`
8990
}
9091

9192
// Adding a struct for the request body of the config apply endpoint.
@@ -574,10 +575,15 @@ func processConfigApplyRequestBody(c *gin.Context, initialFiles []*mpi.File) ([]
574575
file.ExternalDataSource = &mpi.ExternalDataSource{
575576
Location: ed.Location,
576577
}
578+
if file.GetFileMeta() == nil {
579+
file.FileMeta = &mpi.FileMeta{}
580+
}
581+
file.FileMeta.Permissions = ed.Permissions
577582
} else {
578583
newFile := &mpi.File{
579584
FileMeta: &mpi.FileMeta{
580-
Name: ed.FilePath,
585+
Name: ed.FilePath,
586+
Permissions: ed.Permissions,
581587
},
582588
ExternalDataSource: &mpi.ExternalDataSource{
583589
Location: ed.Location,

0 commit comments

Comments
 (0)