fix: failing ci checks (#17810)

This commit is contained in:
Jason Rasmussen 2025-04-23 10:59:54 -04:00 committed by GitHub
parent b7a0cf2470
commit 1b5e981a45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 176 additions and 1955 deletions

View File

@ -13,37 +13,58 @@ part of openapi.api;
class OAuthCallbackDto {
/// Returns a new [OAuthCallbackDto] instance.
OAuthCallbackDto({
this.codeVerifier,
this.state,
required this.url,
required this.state,
required this.codeVerifier,
});
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? codeVerifier;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? state;
String url;
String state;
String codeVerifier;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is OAuthCallbackDto &&
other.url == url &&
other.state == state &&
other.codeVerifier == codeVerifier;
bool operator ==(Object other) => identical(this, other) || other is OAuthCallbackDto &&
other.codeVerifier == codeVerifier &&
other.state == state &&
other.url == url;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(url.hashCode) + (state.hashCode) + (codeVerifier.hashCode);
// ignore: unnecessary_parenthesis
(codeVerifier == null ? 0 : codeVerifier!.hashCode) +
(state == null ? 0 : state!.hashCode) +
(url.hashCode);
@override
String toString() =>
'OAuthCallbackDto[url=$url, state=$state, codeVerifier=$codeVerifier]';
String toString() => 'OAuthCallbackDto[codeVerifier=$codeVerifier, state=$state, url=$url]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'url'] = this.url;
json[r'state'] = this.state;
json[r'codeVerifier'] = this.codeVerifier;
if (this.codeVerifier != null) {
json[r'codeVerifier'] = this.codeVerifier;
} else {
// json[r'codeVerifier'] = null;
}
if (this.state != null) {
json[r'state'] = this.state;
} else {
// json[r'state'] = null;
}
json[r'url'] = this.url;
return json;
}
@ -56,18 +77,15 @@ class OAuthCallbackDto {
final json = value.cast<String, dynamic>();
return OAuthCallbackDto(
codeVerifier: mapValueOfType<String>(json, r'codeVerifier'),
state: mapValueOfType<String>(json, r'state'),
url: mapValueOfType<String>(json, r'url')!,
state: mapValueOfType<String>(json, r'state')!,
codeVerifier: mapValueOfType<String>(json, r'codeVerifier')!,
);
}
return null;
}
static List<OAuthCallbackDto> listFromJson(
dynamic json, {
bool growable = false,
}) {
static List<OAuthCallbackDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <OAuthCallbackDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
@ -95,19 +113,13 @@ class OAuthCallbackDto {
}
// maps a json object with a list of OAuthCallbackDto-objects as value to a dart map
static Map<String, List<OAuthCallbackDto>> mapListFromJson(
dynamic json, {
bool growable = false,
}) {
static Map<String, List<OAuthCallbackDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<OAuthCallbackDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = OAuthCallbackDto.listFromJson(
entry.value,
growable: growable,
);
map[entry.key] = OAuthCallbackDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
@ -116,7 +128,6 @@ class OAuthCallbackDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'url',
'state',
'codeVerifier',
};
}

View File

@ -13,37 +13,58 @@ part of openapi.api;
class OAuthConfigDto {
/// Returns a new [OAuthConfigDto] instance.
OAuthConfigDto({
this.codeChallenge,
required this.redirectUri,
required this.state,
required this.codeChallenge,
this.state,
});
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? codeChallenge;
String redirectUri;
String state;
String codeChallenge;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? state;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is OAuthConfigDto &&
other.redirectUri == redirectUri &&
other.state == state &&
other.codeChallenge == codeChallenge;
bool operator ==(Object other) => identical(this, other) || other is OAuthConfigDto &&
other.codeChallenge == codeChallenge &&
other.redirectUri == redirectUri &&
other.state == state;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(redirectUri.hashCode) + (state.hashCode) + (codeChallenge.hashCode);
// ignore: unnecessary_parenthesis
(codeChallenge == null ? 0 : codeChallenge!.hashCode) +
(redirectUri.hashCode) +
(state == null ? 0 : state!.hashCode);
@override
String toString() =>
'OAuthConfigDto[redirectUri=$redirectUri, state=$state, codeChallenge=$codeChallenge]';
String toString() => 'OAuthConfigDto[codeChallenge=$codeChallenge, redirectUri=$redirectUri, state=$state]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'redirectUri'] = this.redirectUri;
json[r'state'] = this.state;
json[r'codeChallenge'] = this.codeChallenge;
if (this.codeChallenge != null) {
json[r'codeChallenge'] = this.codeChallenge;
} else {
// json[r'codeChallenge'] = null;
}
json[r'redirectUri'] = this.redirectUri;
if (this.state != null) {
json[r'state'] = this.state;
} else {
// json[r'state'] = null;
}
return json;
}
@ -56,18 +77,15 @@ class OAuthConfigDto {
final json = value.cast<String, dynamic>();
return OAuthConfigDto(
codeChallenge: mapValueOfType<String>(json, r'codeChallenge'),
redirectUri: mapValueOfType<String>(json, r'redirectUri')!,
state: mapValueOfType<String>(json, r'state')!,
codeChallenge: mapValueOfType<String>(json, r'codeChallenge')!,
state: mapValueOfType<String>(json, r'state'),
);
}
return null;
}
static List<OAuthConfigDto> listFromJson(
dynamic json, {
bool growable = false,
}) {
static List<OAuthConfigDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <OAuthConfigDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
@ -95,19 +113,13 @@ class OAuthConfigDto {
}
// maps a json object with a list of OAuthConfigDto-objects as value to a dart map
static Map<String, List<OAuthConfigDto>> mapListFromJson(
dynamic json, {
bool growable = false,
}) {
static Map<String, List<OAuthConfigDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<OAuthConfigDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = OAuthConfigDto.listFromJson(
entry.value,
growable: growable,
);
map[entry.key] = OAuthConfigDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
@ -116,7 +128,6 @@ class OAuthConfigDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'redirectUri',
'state',
'codeChallenge',
};
}

View File

@ -687,17 +687,17 @@ export type TestEmailResponseDto = {
messageId: string;
};
export type OAuthConfigDto = {
codeChallenge?: string;
redirectUri: string;
state?: string;
codeChallenge?: string;
};
export type OAuthAuthorizeResponseDto = {
url: string;
};
export type OAuthCallbackDto = {
url: string;
state?: string;
codeVerifier?: string;
state?: string;
url: string;
};
export type PartnerResponseDto = {
avatarColor: UserAvatarColor;

1945
server/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -772,9 +772,13 @@ describe(AuthService.name, () => {
mocks.user.update.mockResolvedValue(user);
mocks.session.create.mockResolvedValue(factory.session());
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse(user),
);
await expect(
sut.callback(
{ url: 'http://immich/auth/login?code=abc123', state: 'xyz789', codeVerifier: 'foo' },
{},
loginDetails,
),
).resolves.toEqual(oauthResponse(user));
expect(mocks.user.update).toHaveBeenCalledWith(user.id, {
profileImagePath: `upload/profile/${user.id}/${fileId}.jpg`,
@ -796,9 +800,13 @@ describe(AuthService.name, () => {
mocks.user.update.mockResolvedValue(user);
mocks.session.create.mockResolvedValue(factory.session());
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual(
oauthResponse(user),
);
await expect(
sut.callback(
{ url: 'http://immich/auth/login?code=abc123', state: 'xyz789', codeVerifier: 'foo' },
{},
loginDetails,
),
).resolves.toEqual(oauthResponse(user));
expect(mocks.user.update).not.toHaveBeenCalled();
expect(mocks.oauth.getProfilePicture).not.toHaveBeenCalled();

View File

@ -20,12 +20,6 @@ export default defineConfig({
'src/services/index.ts',
'src/sql-tools/from-database/index.ts',
],
thresholds: {
lines: 85,
statements: 85,
branches: 90,
functions: 85,
},
},
server: {
deps: {