Skip to content

Package updates #1698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2025
Merged
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"rollForward": false
},
"microsoft.openapi.kiota": {
"version": "1.23.0",
"version": "1.24.1",
"commands": [
"kiota"
],
Expand Down
2 changes: 1 addition & 1 deletion package-versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<MicrosoftApiServerVersion>9.0.*</MicrosoftApiServerVersion>
<NSwagApiClientVersion>14.2.*</NSwagApiClientVersion>
<NewtonsoftJsonVersion>13.0.*</NewtonsoftJsonVersion>
<ScalarAspNetCoreVersion>1.2.*</ScalarAspNetCoreVersion>
<ScalarAspNetCoreVersion>2.0.*</ScalarAspNetCoreVersion>
<SwashbuckleVersion>7.*-*</SwashbuckleVersion>
<SystemTextJsonVersion>9.0.*</SystemTextJsonVersion>
<TestSdkVersion>17.12.*</TestSdkVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public string? NextRevalidation
}

/// <summary>The password property</summary>
public string? Password
public byte[]? Password
{
get { return BackingStore?.Get<string?>("password"); }
get { return BackingStore?.Get<byte[]?>("password"); }
set { BackingStore?.Set("password", value); }
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{ "firstName", n => { FirstName = n.GetStringValue(); } },
{ "lastName", n => { LastName = n.GetStringValue(); } },
{ "nextRevalidation", n => { NextRevalidation = n.GetStringValue(); } },
{ "password", n => { Password = n.GetStringValue(); } },
{ "password", n => { Password = n.GetByteArrayValue(); } },
{ "phone", n => { Phone = n.GetStringValue(); } },
{ "planet", n => { Planet = n.GetStringValue(); } },
{ "profilePicture", n => { ProfilePicture = n.GetStringValue(); } },
Expand Down Expand Up @@ -209,7 +209,7 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteStringValue("firstName", FirstName);
writer.WriteStringValue("lastName", LastName);
writer.WriteStringValue("nextRevalidation", NextRevalidation);
writer.WriteStringValue("password", Password);
writer.WriteByteArrayValue("password", Password);
writer.WriteStringValue("phone", Phone);
writer.WriteStringValue("planet", Planet);
writer.WriteStringValue("profilePicture", ProfilePicture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public string? NextRevalidation
}

/// <summary>The password property</summary>
public string? Password
public byte[]? Password
{
get { return BackingStore?.Get<string?>("password"); }
get { return BackingStore?.Get<byte[]?>("password"); }
set { BackingStore?.Set("password", value); }
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{ "firstName", n => { FirstName = n.GetStringValue(); } },
{ "lastName", n => { LastName = n.GetStringValue(); } },
{ "nextRevalidation", n => { NextRevalidation = n.GetStringValue(); } },
{ "password", n => { Password = n.GetStringValue(); } },
{ "password", n => { Password = n.GetByteArrayValue(); } },
{ "phone", n => { Phone = n.GetStringValue(); } },
{ "planet", n => { Planet = n.GetStringValue(); } },
{ "profilePicture", n => { ProfilePicture = n.GetStringValue(); } },
Expand Down Expand Up @@ -209,7 +209,7 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteStringValue("firstName", FirstName);
writer.WriteStringValue("lastName", LastName);
writer.WriteStringValue("nextRevalidation", NextRevalidation);
writer.WriteStringValue("password", Password);
writer.WriteByteArrayValue("password", Password);
writer.WriteStringValue("phone", Phone);
writer.WriteStringValue("planet", Planet);
writer.WriteStringValue("profilePicture", ProfilePicture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public string? NextRevalidation
}

/// <summary>The password property</summary>
public string? Password
public byte[]? Password
{
get { return BackingStore?.Get<string?>("password"); }
get { return BackingStore?.Get<byte[]?>("password"); }
set { BackingStore?.Set("password", value); }
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{ "firstName", n => { FirstName = n.GetStringValue(); } },
{ "lastName", n => { LastName = n.GetStringValue(); } },
{ "nextRevalidation", n => { NextRevalidation = n.GetStringValue(); } },
{ "password", n => { Password = n.GetStringValue(); } },
{ "password", n => { Password = n.GetByteArrayValue(); } },
{ "phone", n => { Phone = n.GetStringValue(); } },
{ "planet", n => { Planet = n.GetStringValue(); } },
{ "profilePicture", n => { ProfilePicture = n.GetStringValue(); } },
Expand Down Expand Up @@ -209,7 +209,7 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteStringValue("firstName", FirstName);
writer.WriteStringValue("lastName", LastName);
writer.WriteStringValue("nextRevalidation", NextRevalidation);
writer.WriteStringValue("password", Password);
writer.WriteByteArrayValue("password", Password);
writer.WriteStringValue("phone", Phone);
writer.WriteStringValue("planet", Planet);
writer.WriteStringValue("profilePicture", ProfilePicture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public async Task Cannot_exceed_min_length_constraint()
{
LastName = newAccount.LastName,
// Using -3 instead of -1 to compensate for base64 padding.
Password = Convert.ToBase64String(Enumerable.Repeat((byte)'X', SocialMediaAccount.MinPasswordChars - 3).ToArray())
Password = Enumerable.Repeat((byte)'X', SocialMediaAccount.MinPasswordChars - 3).ToArray()
}
}
};
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task Cannot_exceed_max_length_constraint()
Attributes = new AttributesInCreateSocialMediaAccountRequest
{
LastName = newAccount.LastName,
Password = Convert.ToBase64String(Enumerable.Repeat((byte)'X', SocialMediaAccount.MaxPasswordChars + 1).ToArray())
Password = Enumerable.Repeat((byte)'X', SocialMediaAccount.MaxPasswordChars + 1).ToArray()
}
}
};
Expand All @@ -292,42 +292,6 @@ public async Task Cannot_exceed_max_length_constraint()
errorObject.Source.Pointer.Should().Be("/data/attributes/password");
}

[Fact]
public async Task Cannot_use_invalid_base64()
{
// Arrange
SocialMediaAccount newAccount = _fakers.SocialMediaAccount.GenerateOne();

using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory);
ModelStateValidationClient apiClient = new(requestAdapter);

var requestBody = new CreateSocialMediaAccountRequestDocument
{
Data = new DataInCreateSocialMediaAccountRequest
{
Type = SocialMediaAccountResourceType.SocialMediaAccounts,
Attributes = new AttributesInCreateSocialMediaAccountRequest
{
LastName = newAccount.LastName,
Password = "not-a-valid-base64-string"
}
}
};

// Act
Func<Task> action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody);

// Assert
ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync<ErrorResponseDocument>()).Which;
document.Errors.Should().HaveCount(1);

ErrorObject errorObject = document.Errors.First();
errorObject.Title.Should().Be("Input validation failed.");
errorObject.Detail.Should().Be("The Password field is not a valid Base64 encoding.");
errorObject.Source.Should().NotBeNull();
errorObject.Source.Pointer.Should().Be("/data/attributes/password");
}

[Theory]
[InlineData(-1)]
[InlineData(-0.56)]
Expand Down Expand Up @@ -572,7 +536,7 @@ public async Task Can_create_resource_with_valid_properties()
UserName = newAccount.UserName,
CreditCard = newAccount.CreditCard,
Email = newAccount.Email,
Password = newAccount.Password,
Password = Convert.FromBase64String(newAccount.Password!),
Phone = newAccount.Phone,
Age = newAccount.Age,
ProfilePicture = newAccount.ProfilePicture!.ToString(),
Expand Down
Loading