Skip to content

Commit

Permalink
fix: 🐛 BankID urls changed (kolplattformen#646)
Browse files Browse the repository at this point in the history
* fix: 🐛 BankID urls changed

* lint

* fix: 🐛 Tests
  • Loading branch information
kajetan-kazimierczak authored Mar 21, 2023
1 parent 0db53ca commit 25a2d7f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion apps/skolplattformen-app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 20000
versionName "3.0.5"
versionName "3.0.6"
}
splits {
abi {
Expand Down
4 changes: 2 additions & 2 deletions apps/skolplattformen-app/ios/app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
ENABLE_BITCODE = NO;
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 3.0.5;
MARKETING_VERSION = 3.0.6;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -823,7 +823,7 @@
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 3.0.5;
MARKETING_VERSION = 3.0.6;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ exports[`handles route classmates 1`] = `"https://etjanst.stockholm.se/vardnadsh

exports[`handles route image 1`] = `"https://etjanst.stockholm.se/vardnadshavare/inloggad2/NewsBanner?url=https://example.com/img.png"`;

exports[`handles route login with personal number 1`] = `"https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt&initialize=bankid&personalNumber=201701012393&_=1618404258782"`;
exports[`handles route login with personal number 1`] = `"https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TYPE=33554433&REALMOID=06-42f40edd-0c5b-4dbc-b714-1be1e907f2de&GUID=1&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=IfNE0iMOtzq2TcxFADHylR6rkmFtwzoxRKh5nRMO9NBqIxHrc38jFyt56FASdxk1&TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt&initialize=bankid&personalNumber=201701012393&_=1618404258782"`;

exports[`handles route login without personal number 1`] = `"https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt&initialize=bankid&_=1618404258782"`;
exports[`handles route login without personal number 1`] = `"https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TYPE=33554433&REALMOID=06-42f40edd-0c5b-4dbc-b714-1be1e907f2de&GUID=1&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=IfNE0iMOtzq2TcxFADHylR6rkmFtwzoxRKh5nRMO9NBqIxHrc38jFyt56FASdxk1&TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt&initialize=bankid&_=1618404258782"`;

exports[`handles route menuChoice 1`] = `"https://etjanst.stockholm.se/vardnadshavare/inloggad2/Matsedel/GetMatsedelChoice?childId=123"`;

Expand Down
14 changes: 9 additions & 5 deletions libs/api-skolplattformen/lib/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ describe('api', () => {
token: '9462cf77-bde9-4029-bb41-e599f3094613',
order: '5fe57e4c-9ad2-4b52-b794-48adef2f6663',
}
const pending = { state: 'PENDING' }
response.json.mockResolvedValue(data)
response.text.mockResolvedValue('PENDING')
response.json.mockResolvedValue(pending)

const personalNumber = 'my personal number'
api.login(personalNumber).then((status) => {
Expand All @@ -60,14 +61,16 @@ describe('api', () => {
token: '9462cf77-bde9-4029-bb41-e599f3094613',
order: '5fe57e4c-9ad2-4b52-b794-48adef2f6663',
}
const pending = { state: 'PENDING' }
const ok = { state: 'OK' }
response.json.mockResolvedValue(data)
response.text.mockResolvedValueOnce('PENDING')
response.text.mockResolvedValueOnce('OK')
response.json.mockResolvedValueOnce(pending)
response.json.mockResolvedValueOnce(ok)

const personalNumber = 'my personal number'
api.login(personalNumber).then((status) => {
status.on('OK', () => {
expect(fetch).toHaveBeenCalledTimes(4)
expect(fetch).toHaveBeenCalledTimes(3)
done()
})
})
Expand All @@ -89,8 +92,9 @@ describe('api', () => {
token: '9462cf77-bde9-4029-bb41-e599f3094613',
order: '5fe57e4c-9ad2-4b52-b794-48adef2f6663',
}
const error = { state: 'ERROR' }
response.json.mockResolvedValue(data)
response.text.mockResolvedValueOnce('ERROR')
response.json.mockResolvedValue(error)

const personalNumber = 'my personal number'
api.login(personalNumber).then((status) => {
Expand Down
10 changes: 5 additions & 5 deletions libs/api-skolplattformen/lib/loginStatusChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class Checker extends EventEmitter implements LoginStatusChecker {

async check(): Promise<void> {
const response = await this.fetcher('login-status', this.url)
const status = await response.text()
this.emit(status)
const status = await response.json()
this.emit(status.state)
if (
!this.cancelled &&
status !== 'OK' &&
status !== 'ERROR!' &&
status !== 'CANCELLED'
status.state !== 'OK' &&
status.state !== 'ERROR' &&
status.state !== 'CANCELLED'
) {
setTimeout(() => this.check(), 1000)
}
Expand Down
5 changes: 2 additions & 3 deletions libs/api-skolplattformen/lib/routes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// BankId
export const login = (personalNumber?: string) => {
const baseUrl =
'https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt'
'https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TYPE=33554433&REALMOID=06-42f40edd-0c5b-4dbc-b714-1be1e907f2de&GUID=1&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=IfNE0iMOtzq2TcxFADHylR6rkmFtwzoxRKh5nRMO9NBqIxHrc38jFyt56FASdxk1&TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt'
const optionalPersonalNumber =
personalNumber === undefined ? '' : `&personalNumber=${personalNumber}`
return `${baseUrl}&initialize=bankid${optionalPersonalNumber}&_=${Date.now()}`
}

export const loginStatus = (order: string) =>
`https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt&verifyorder=${order}&_=${Date.now()}`

`https://login003.stockholm.se/NECSadcmbid/authenticate/NECSadcmbid?TYPE=33554433&REALMOID=06-42f40edd-0c5b-4dbc-b714-1be1e907f2de&GUID=1&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=IfNE0iMOtzq2TcxFADHylR6rkmFtwzoxRKh5nRMO9NBqIxHrc38jFyt56FASdxk1&TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvaGVt&verifyorder=${order}&_=${Date.now()}`
export const loginCookie =
'https://login003.stockholm.se/NECSadcmbid/authenticate/SiteMinderAuthADC?TYPE=33554433&REALMOID=06-42f40edd-0c5b-4dbc-b714-1be1e907f2de&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=IfNE0iMOtzq2TcxFADHylR6rkmFtwzoxRKh5nRMO9NBqIxHrc38jFyt56FASdxk1&TARGET=-SM-HTTPS%3a%2f%2flogin001%2estockholm%2ese%2fNECSadc%2fmbid%2fb64startpage%2ejsp%3fstartpage%3daHR0cHM6Ly9ldGphbnN0LnN0b2NraG9sbS5zZS92YXJkbmFkc2hhdmFyZS9pbmxvZ2dhZDIvR2V0Q2hpbGRyZW4%3d'

Expand Down

0 comments on commit 25a2d7f

Please sign in to comment.