Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ message AzureGalleryImageProperties {
string sasURI = 1 [(sensitive) = true];
string version = 2;
}
message AzureBlobImageProperties {
string catalogName = 1;
string audience = 2;
string version = 3;
string releaseName = 4;
uint32 parts = 5;
string cloud = 6;
string endpoint = 7;
}

message GalleryImage {
string name = 1;
Expand Down
201 changes: 146 additions & 55 deletions rpc/cloudagent/compute/moc_cloudagent_galleryimage.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions rpc/cloudagent/compute/moc_cloudagent_galleryimage_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the Apache v2.0 license.
package compute

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// TestAzureBlobImageProperties_JSONKeys locks the exact JSON keys produced by
// the cloudagent AzureBlobImageProperties message. moc-sdk-for-go marshals
// this struct into GalleryImage.sourcePath as the on-the-wire representation
// of AGC (AZURESTORAGEBLOB_SOURCE) image provisioning parameters. Renaming any
// of these proto fields would silently break the encoding agreement with
// wssdagent's parseBlobConfig on the decode side, so this test fails loudly
// if a field name drifts.
func TestAzureBlobImageProperties_JSONKeys(t *testing.T) {
props := AzureBlobImageProperties{
CatalogName: "cat",
Audience: "aud",
Version: "v1",
ReleaseName: "rel",
Parts: 4,
Cloud: "AzureCloud",
Endpoint: "https://example.blob.core.windows.net",
}
raw, err := json.Marshal(&props)
require.NoError(t, err)

var m map[string]any
require.NoError(t, json.Unmarshal(raw, &m))

expected := []string{"catalogName", "audience", "version", "releaseName", "parts", "cloud", "endpoint"}
for _, key := range expected {
_, ok := m[key]
assert.True(t, ok, "missing JSON key %q (renamed proto field?)", key)
}
assert.Len(t, m, len(expected), "unexpected extra/missing JSON keys: %v", m)
}
Loading
Loading