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 { class OAuthCallbackDto {
/// Returns a new [OAuthCallbackDto] instance. /// Returns a new [OAuthCallbackDto] instance.
OAuthCallbackDto({ OAuthCallbackDto({
this.codeVerifier,
this.state,
required this.url, 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 url;
String state;
String codeVerifier;
@override @override
bool operator ==(Object other) => bool operator ==(Object other) => identical(this, other) || other is OAuthCallbackDto &&
identical(this, other) || other.codeVerifier == codeVerifier &&
other is OAuthCallbackDto &&
other.url == url &&
other.state == state && other.state == state &&
other.codeVerifier == codeVerifier; other.url == url;
@override @override
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(url.hashCode) + (state.hashCode) + (codeVerifier.hashCode); (codeVerifier == null ? 0 : codeVerifier!.hashCode) +
(state == null ? 0 : state!.hashCode) +
(url.hashCode);
@override @override
String toString() => String toString() => 'OAuthCallbackDto[codeVerifier=$codeVerifier, state=$state, url=$url]';
'OAuthCallbackDto[url=$url, state=$state, codeVerifier=$codeVerifier]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
json[r'url'] = this.url; if (this.codeVerifier != null) {
json[r'state'] = this.state;
json[r'codeVerifier'] = this.codeVerifier; 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; return json;
} }
@ -56,18 +77,15 @@ class OAuthCallbackDto {
final json = value.cast<String, dynamic>(); final json = value.cast<String, dynamic>();
return OAuthCallbackDto( return OAuthCallbackDto(
codeVerifier: mapValueOfType<String>(json, r'codeVerifier'),
state: mapValueOfType<String>(json, r'state'),
url: mapValueOfType<String>(json, r'url')!, url: mapValueOfType<String>(json, r'url')!,
state: mapValueOfType<String>(json, r'state')!,
codeVerifier: mapValueOfType<String>(json, r'codeVerifier')!,
); );
} }
return null; return null;
} }
static List<OAuthCallbackDto> listFromJson( static List<OAuthCallbackDto> listFromJson(dynamic json, {bool growable = false,}) {
dynamic json, {
bool growable = false,
}) {
final result = <OAuthCallbackDto>[]; final result = <OAuthCallbackDto>[];
if (json is List && json.isNotEmpty) { if (json is List && json.isNotEmpty) {
for (final row in json) { 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 // maps a json object with a list of OAuthCallbackDto-objects as value to a dart map
static Map<String, List<OAuthCallbackDto>> mapListFromJson( static Map<String, List<OAuthCallbackDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
dynamic json, {
bool growable = false,
}) {
final map = <String, List<OAuthCallbackDto>>{}; final map = <String, List<OAuthCallbackDto>>{};
if (json is Map && json.isNotEmpty) { if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments // ignore: parameter_assignments
json = json.cast<String, dynamic>(); json = json.cast<String, dynamic>();
for (final entry in json.entries) { for (final entry in json.entries) {
map[entry.key] = OAuthCallbackDto.listFromJson( map[entry.key] = OAuthCallbackDto.listFromJson(entry.value, growable: growable,);
entry.value,
growable: growable,
);
} }
} }
return map; return map;
@ -116,7 +128,6 @@ class OAuthCallbackDto {
/// The list of required keys that must be present in a JSON. /// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{ static const requiredKeys = <String>{
'url', 'url',
'state',
'codeVerifier',
}; };
} }

View File

@ -13,37 +13,58 @@ part of openapi.api;
class OAuthConfigDto { class OAuthConfigDto {
/// Returns a new [OAuthConfigDto] instance. /// Returns a new [OAuthConfigDto] instance.
OAuthConfigDto({ OAuthConfigDto({
this.codeChallenge,
required this.redirectUri, required this.redirectUri,
required this.state, this.state,
required this.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? codeChallenge;
String redirectUri; 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 @override
bool operator ==(Object other) => bool operator ==(Object other) => identical(this, other) || other is OAuthConfigDto &&
identical(this, other) || other.codeChallenge == codeChallenge &&
other is OAuthConfigDto &&
other.redirectUri == redirectUri && other.redirectUri == redirectUri &&
other.state == state && other.state == state;
other.codeChallenge == codeChallenge;
@override @override
int get hashCode => int get hashCode =>
// ignore: unnecessary_parenthesis // ignore: unnecessary_parenthesis
(redirectUri.hashCode) + (state.hashCode) + (codeChallenge.hashCode); (codeChallenge == null ? 0 : codeChallenge!.hashCode) +
(redirectUri.hashCode) +
(state == null ? 0 : state!.hashCode);
@override @override
String toString() => String toString() => 'OAuthConfigDto[codeChallenge=$codeChallenge, redirectUri=$redirectUri, state=$state]';
'OAuthConfigDto[redirectUri=$redirectUri, state=$state, codeChallenge=$codeChallenge]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
json[r'redirectUri'] = this.redirectUri; if (this.codeChallenge != null) {
json[r'state'] = this.state;
json[r'codeChallenge'] = this.codeChallenge; 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; return json;
} }
@ -56,18 +77,15 @@ class OAuthConfigDto {
final json = value.cast<String, dynamic>(); final json = value.cast<String, dynamic>();
return OAuthConfigDto( return OAuthConfigDto(
codeChallenge: mapValueOfType<String>(json, r'codeChallenge'),
redirectUri: mapValueOfType<String>(json, r'redirectUri')!, redirectUri: mapValueOfType<String>(json, r'redirectUri')!,
state: mapValueOfType<String>(json, r'state')!, state: mapValueOfType<String>(json, r'state'),
codeChallenge: mapValueOfType<String>(json, r'codeChallenge')!,
); );
} }
return null; return null;
} }
static List<OAuthConfigDto> listFromJson( static List<OAuthConfigDto> listFromJson(dynamic json, {bool growable = false,}) {
dynamic json, {
bool growable = false,
}) {
final result = <OAuthConfigDto>[]; final result = <OAuthConfigDto>[];
if (json is List && json.isNotEmpty) { if (json is List && json.isNotEmpty) {
for (final row in json) { 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 // maps a json object with a list of OAuthConfigDto-objects as value to a dart map
static Map<String, List<OAuthConfigDto>> mapListFromJson( static Map<String, List<OAuthConfigDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
dynamic json, {
bool growable = false,
}) {
final map = <String, List<OAuthConfigDto>>{}; final map = <String, List<OAuthConfigDto>>{};
if (json is Map && json.isNotEmpty) { if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments // ignore: parameter_assignments
json = json.cast<String, dynamic>(); json = json.cast<String, dynamic>();
for (final entry in json.entries) { for (final entry in json.entries) {
map[entry.key] = OAuthConfigDto.listFromJson( map[entry.key] = OAuthConfigDto.listFromJson(entry.value, growable: growable,);
entry.value,
growable: growable,
);
} }
} }
return map; return map;
@ -116,7 +128,6 @@ class OAuthConfigDto {
/// The list of required keys that must be present in a JSON. /// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{ static const requiredKeys = <String>{
'redirectUri', 'redirectUri',
'state',
'codeChallenge',
}; };
} }

View File

@ -687,17 +687,17 @@ export type TestEmailResponseDto = {
messageId: string; messageId: string;
}; };
export type OAuthConfigDto = { export type OAuthConfigDto = {
codeChallenge?: string;
redirectUri: string; redirectUri: string;
state?: string; state?: string;
codeChallenge?: string;
}; };
export type OAuthAuthorizeResponseDto = { export type OAuthAuthorizeResponseDto = {
url: string; url: string;
}; };
export type OAuthCallbackDto = { export type OAuthCallbackDto = {
url: string;
state?: string;
codeVerifier?: string; codeVerifier?: string;
state?: string;
url: string;
}; };
export type PartnerResponseDto = { export type PartnerResponseDto = {
avatarColor: UserAvatarColor; 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.user.update.mockResolvedValue(user);
mocks.session.create.mockResolvedValue(factory.session()); mocks.session.create.mockResolvedValue(factory.session());
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(
oauthResponse(user), 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, { expect(mocks.user.update).toHaveBeenCalledWith(user.id, {
profileImagePath: `upload/profile/${user.id}/${fileId}.jpg`, profileImagePath: `upload/profile/${user.id}/${fileId}.jpg`,
@ -796,9 +800,13 @@ describe(AuthService.name, () => {
mocks.user.update.mockResolvedValue(user); mocks.user.update.mockResolvedValue(user);
mocks.session.create.mockResolvedValue(factory.session()); mocks.session.create.mockResolvedValue(factory.session());
await expect(sut.callback({ url: 'http://immich/auth/login?code=abc123' }, loginDetails)).resolves.toEqual( await expect(
oauthResponse(user), 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.user.update).not.toHaveBeenCalled();
expect(mocks.oauth.getProfilePicture).not.toHaveBeenCalled(); expect(mocks.oauth.getProfilePicture).not.toHaveBeenCalled();

View File

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