Skip to content

Commit

Permalink
[#159265784] add mobile phone to user's attributes (#262)
Browse files Browse the repository at this point in the history
* added mobile phone

* added mobile phone

* added mobile phone

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* update spid-passport

* update spid-passport

* update spid-passport

* update spid-passport

* update spid-passport

* update spid-passport

* update spid-passport

* update spid-passport

* yarn lock

* added mobile phone to pagopa user
  • Loading branch information
gunzip authored Jul 26, 2018
1 parent c7ee967 commit 9c4d7da
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 8 deletions.
10 changes: 10 additions & 0 deletions api_pagopa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,20 @@ definitions:
description: User data needed by PagaPA proxy.
type: object
properties:
name:
type: string
family_name:
type: string
email:
$ref: '#/definitions/EmailAddress'
mobile_phone:
type: string
minLength: 1
required:
- name
- family_name
- email
- mobile_phone
responses: {}
parameters: {}
consumes:
Expand Down
8 changes: 8 additions & 0 deletions api_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ definitions:
type: string
spid_email:
$ref: '#/definitions/EmailAddress'
spid_mobile_phone:
type: string
minLength: 1
preferred_languages:
type: array
items:
Expand All @@ -492,6 +495,7 @@ definitions:
- is_webhook_enabled
- name
- spid_email
- spid_mobile_phone
- version
ProfileWithoutEmail:
type: object
Expand All @@ -514,6 +518,9 @@ definitions:
type: string
spid_email:
$ref: '#/definitions/EmailAddress'
spid_mobile_phone:
type: string
minLength: 1
preferred_languages:
type: array
items:
Expand All @@ -529,6 +536,7 @@ definitions:
- is_webhook_enabled
- name
- spid_email
- spid_mobile_phone
- version
PublicSession:
type: object
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"redis": "^2.8.0",
"redis-clustr": "^1.6.0",
"request-ip": "^2.1.1",
"spid-passport": "git://github.com/gunzip/spid-passport.git#5cd9f353",
"spid-passport": "git://github.com/gunzip/spid-passport.git#5900adf9",
"typescript": "^2.9.2",
"ulid": "^2.2.2",
"validator": "^10.4.0",
Expand Down
11 changes: 8 additions & 3 deletions src/controllers/__tests__/authenticationController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* tslint:disable:no-big-function */

import { left, right } from "fp-ts/lib/Either";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { UrlFromString } from "italia-ts-commons/lib/url";
import * as lolex from "lolex";
import * as redis from "redis";
Expand Down Expand Up @@ -109,6 +110,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "xxx",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: mockWalletToken as WalletToken
};

Expand All @@ -122,6 +124,7 @@ const validUserPayload = {
issuer: {
_: "xxx"
},
mobilePhone: "3222222222222",
name: aValidname,
nameID: "garibaldi",
nameIDFormat: aValidIDFormat,
Expand All @@ -136,6 +139,7 @@ const invalidUserPayload = {
issuer: {
_: "xxx"
},
mobilePhone: "3222222222222",
name: aValidname,
nameID: "garibaldi",
nameIDFormat: aValidIDFormat,
Expand Down Expand Up @@ -428,14 +432,15 @@ IFJiDanROwzoG0YNd8aCWE8ZM2y81Ww=
<RequestedAttribute Name="name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" FriendlyName="Nome"/>
<RequestedAttribute Name="familyName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" FriendlyName="Cognome"/>
<RequestedAttribute Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" FriendlyName="Email"/>
<RequestedAttribute Name="mobilePhone" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" FriendlyName="Numero di telefono"/>
</AttributeConsumingService>
</SPSSODescriptor>
<Organization>
<OrganizationName>Digital citizenship proxy</OrganizationName>
<OrganizationDisplayName>Digital citizenship proxy</OrganizationDisplayName>
<OrganizationURL>https://github.com/teamdigitale/italia-backend</OrganizationURL>
</Organization>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI="#http___italia_backend"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>Mh1V7fJl+pMthhcJAAhEBuY58dWxqd3NI2ha/JyPpeI=</DigestValue></Reference></SignedInfo><SignatureValue>SIzSS+ZwK00YtvsXR8odCkrkBapatSdy8n4ifLl0/zoRQM7UCPrSKbUWihMBJCe7HdoT4VXOhhhgo9+IdE1qunrxQ1a3ydQbySRAidtaGbOQf5JxfzH0zYcKCQJLRPMXtLBNL3qlt+np0Bf740ZpzaKHRktaRn/0yKEHEtE9khf8d2xuzIm/fw75L2/i7wSggNFSUBzwSGd8EN3XRFWgwUuIwP6NK8GAjZa7pO0sZ0Z2zqCL1Q75/FZqaRBqvkrGDmlVu7wRJDTY6WSlzQ7PdhrLyGb4pxjWER0SfnKJBskS9SVjPP9ypb/AoQB6zoFX/58NtDUaluBr3jgxvWLH5R4=</SignatureValue><KeyInfo><X509Data><X509Certificate>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI="#http___italia_backend"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>Bf2Cp9GHtyquphvca26konsKBCC5ZWZE/Jg/ouPscmg=</DigestValue></Reference></SignedInfo><SignatureValue>Xy6T5fn1q2IS0GCXkfOccJv4rF+QrUshbV4hcn/XCfeGSX+C9Kunxx2+BuVMOpuTjtYGUxgCEdMAGOGbaOtCM8pE0XlrCDrAibvSYMvREYSWIWg6ljpUpnPTkM8YNlkot7Gl5Vs7sR3+5vA00SvudJqElttDo3/jrMLGSp4QmX5pcoycmvxummZ4rVktxhQuVdUyODD3Hl+DYJMzkUIBrxz+wR/ysPpi+aBAfNFY+WwTFB/JmVmDHmyoCo02QTaLZqSDRE9JfYU3bmTApqDOwRUAX3MKGx13i/wIw2iqPAakqRM7lHfJBzFS3cTXziCqHB72++pGc/ys9HFoddw+3Is=</SignatureValue><KeyInfo><X509Data><X509Certificate>
MIIDczCCAlqgAwIBAgIBADANBgkqhkiG9w0BAQ0FADBTMQswCQYDVQQGEwJpdDEN
MAsGA1UECAwEUm9tZTEUMBIGA1UECgwLYWdpZC5nb3YuaXQxHzAdBgNVBAMMFmh0
dHBzOi8vaXRhbGlhLWJhY2tlbmQwHhcNMTcxMDI2MTAzNTQwWhcNMTgxMDI2MTAz
Expand All @@ -457,8 +462,8 @@ OM+P8UsrYi2KZuyzSrHq5c0GJz0UzSs8cIDC/CPEajx2Uy+7TABwR4d20Hyo6WIm
IFJiDanROwzoG0YNd8aCWE8ZM2y81Ww=
</X509Certificate></X509Data></KeyInfo></Signature></EntityDescriptor>`;

const matadata = await controller.metadata();
matadata.apply(res);
const metadata = await controller.metadata();
metadata.apply(res);

expect(controller).toBeTruthy();
expect(res.status).toHaveBeenCalledWith(200);
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/__tests__/messagesController.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* tslint:disable:no-any */

import { right } from "fp-ts/lib/Either";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import mockReq from "../../__mocks__/request";
import mockRes from "../../__mocks__/response";
import ApiClient from "../../services/apiClientFactory";
Expand Down Expand Up @@ -54,6 +55,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "123hexToken" as WalletToken
};

Expand Down
3 changes: 3 additions & 0 deletions src/controllers/__tests__/notificationController.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ResponseSuccessJson } from "italia-ts-commons/lib/responses";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import mockReq from "../../__mocks__/request";
import mockRes from "../../__mocks__/response";
import NotificationService from "../../services/notificationService";
Expand Down Expand Up @@ -31,6 +32,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "123hexToken" as WalletToken
};

Expand All @@ -46,6 +48,7 @@ const mockedInvalidUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "123hexToken" as WalletToken
};

Expand Down
2 changes: 2 additions & 0 deletions src/controllers/__tests__/profileController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { right } from "fp-ts/lib/Either";
import { NonNegativeInteger } from "italia-ts-commons/lib/numbers";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import mockReq from "../../__mocks__/request";
import mockRes from "../../__mocks__/response";
import ApiClient from "../../services/apiClientFactory";
Expand Down Expand Up @@ -63,6 +64,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "123hexToken" as WalletToken
};

Expand Down
1 change: 1 addition & 0 deletions src/controllers/__tests__/serviceController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "123hexToken" as WalletToken
};

Expand Down
2 changes: 2 additions & 0 deletions src/controllers/__tests__/sessionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* tslint:disable:no-identical-functions */
/* tslint:disable:no-big-function */

import { NonEmptyString } from "italia-ts-commons/lib/strings";
import mockReq from "../../__mocks__/request";
import mockRes from "../../__mocks__/response";
import { EmailAddress } from "../../types/api/EmailAddress";
Expand Down Expand Up @@ -41,6 +42,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "xxx",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: mockWalletToken as WalletToken
};

Expand Down
5 changes: 4 additions & 1 deletion src/controllers/pagoPAController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export default class PagoPAController {
const email = maybeCustomEmail ? maybeCustomEmail : profile.spid_email;

return ResponseSuccessJson({
email
email,
family_name: user.family_name,
mobile_phone: user.spid_mobile_phone,
name: user.name
});
}
}
2 changes: 2 additions & 0 deletions src/services/__tests__/messagesService.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { left, right } from "fp-ts/lib/Either";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { EmailAddress } from "../../types/api/EmailAddress";
import { FiscalCode } from "../../types/api/FiscalCode";
import { SpidLevelEnum } from "../../types/api/SpidLevel";
Expand Down Expand Up @@ -177,6 +178,7 @@ const mockedUser: User = {
spid_email: aValidEmail,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "HexToKen" as WalletToken
};

Expand Down
4 changes: 4 additions & 0 deletions src/services/__tests__/profileService.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { right } from "fp-ts/lib/Either";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { EmailAddress } from "../../types/api/EmailAddress";
import { FiscalCode } from "../../types/api/FiscalCode";
import { IsInboxEnabled } from "../../types/api/IsInboxEnabled";
Expand Down Expand Up @@ -46,6 +47,7 @@ const proxyProfileWithEmailResponse = {
name: "Luca",
preferred_languages: ["it_IT"],
spid_email: aValidSPIDEmail,
spid_mobile_phone: "3222222222222",
version: 42
};
const proxyProfileWithoutEmailResponse = {
Expand All @@ -57,6 +59,7 @@ const proxyProfileWithoutEmailResponse = {
is_webhook_enabled: false,
name: "Luca",
spid_email: aValidSPIDEmail,
spid_mobile_phone: "3222222222222",
version: 0
};
const proxyUpsertRequest = {
Expand Down Expand Up @@ -103,6 +106,7 @@ const mockedUser: User = {
spid_email: aValidSPIDEmail,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "HexToKen" as WalletToken
};

Expand Down
2 changes: 2 additions & 0 deletions src/services/__tests__/redisSessionStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* tslint:disable:no-null-keyword */

import { left, right } from "fp-ts/lib/Either";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import * as lolex from "lolex";
import { createMockRedis } from "mock-redis-client";
import { EmailAddress } from "../../types/api/EmailAddress";
Expand Down Expand Up @@ -35,6 +36,7 @@ const aValidUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "HexToKen" as WalletToken
};

Expand Down
8 changes: 7 additions & 1 deletion src/strategies/spidStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ const spidStrategy = (
acceptedClockSkewMs: samlAcceptedClockSkewMs,
attributeConsumingServiceIndex: samlAttributeConsumingServiceIndex,
attributes: {
attributes: ["fiscalNumber", "name", "familyName", "email"],
attributes: [
"fiscalNumber",
"name",
"familyName",
"email",
"mobilePhone"
],
name: "Required attributes"
},
callbackUrl: samlCallbackUrl,
Expand Down
2 changes: 2 additions & 0 deletions src/types/__tests__/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { isLeft, isRight } from "fp-ts/lib/Either";
import mockReq from "../../__mocks__/request";

import { NonNegativeInteger } from "italia-ts-commons/lib/numbers";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { EmailAddress } from "../api/EmailAddress";
import { ExtendedProfile } from "../api/ExtendedProfile";
import { FiscalCode } from "../api/FiscalCode";
Expand Down Expand Up @@ -55,6 +56,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "HexToKen" as WalletToken
};

Expand Down
3 changes: 3 additions & 0 deletions src/types/__tests__/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Either, isLeft, isRight } from "fp-ts/lib/Either";
import mockReq from "../../__mocks__/request";

import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { EmailAddress } from "../api/EmailAddress";
import { FiscalCode } from "../api/FiscalCode";
import { SpidLevelEnum } from "../api/SpidLevel";
Expand Down Expand Up @@ -31,6 +32,7 @@ const mockedSpidUser: any = {
fiscalNumber: aFiscalNumber,
getAssertionXml: () => "",
issuer: anIssuer,
mobilePhone: "3222222222222",
name: "Giuseppe Maria",
nameID: "garibaldi",
nameIDFormat: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
Expand All @@ -55,6 +57,7 @@ const mockedUser: User = {
spid_email: anEmailAddress,
spid_idp: "spid_idp_name",
spid_level: aValidSpidLevel,
spid_mobile_phone: "3222222222222" as NonEmptyString,
wallet_token: "HexToKen" as WalletToken
};

Expand Down
2 changes: 2 additions & 0 deletions src/types/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function toAppProfileWithEmail(
name: user.name,
preferred_languages: from.preferredLanguages,
spid_email: user.spid_email,
spid_mobile_phone: user.spid_mobile_phone,
version: from.version
};
}
Expand All @@ -54,6 +55,7 @@ export function toAppProfileWithoutEmail(user: User): ProfileWithoutEmail {
is_webhook_enabled: false,
name: user.name,
spid_email: user.spid_email,
spid_mobile_phone: user.spid_mobile_phone,
version: 0 as NonNegativeInteger
};
}
Expand Down
4 changes: 4 additions & 0 deletions src/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { number, string } from "io-ts";
import * as t from "io-ts";
import { JSONFromString } from "io-ts-types";
import { readableReport } from "italia-ts-commons/lib/reporters";
import { NonEmptyString } from "italia-ts-commons/lib/strings";
import { DOMParser } from "xmldom";
import { log } from "../utils/logger";
import { EmailAddress } from "./api/EmailAddress";
Expand All @@ -32,6 +33,7 @@ export const User = t.interface({
spid_email: EmailAddress,
spid_idp: string,
spid_level: SpidLevel,
spid_mobile_phone: NonEmptyString,
wallet_token: WalletToken
});

Expand All @@ -45,6 +47,7 @@ export const SpidUser = t.interface({
fiscalNumber: FiscalCode,
getAssertionXml: t.Function,
issuer: Issuer,
mobilePhone: NonEmptyString,
name: string,
nameID: string,
nameIDFormat: string,
Expand Down Expand Up @@ -73,6 +76,7 @@ export function toAppUser(
spid_email: from.email,
spid_idp: from.issuer._, // The used idp is needed for logout.
spid_level: from.authnContextClassRef,
spid_mobile_phone: from.mobilePhone,
wallet_token: walletToken
};
}
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5197,9 +5197,9 @@ spdx-license-ids@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87"

"spid-passport@git://github.com/gunzip/spid-passport.git#6395dd9e5fdf1ecd48af5f02745a37a7aec9b9d0":
"spid-passport@git://github.com/gunzip/spid-passport.git#5900adf9":
version "1.0.0"
resolved "git://github.com/gunzip/spid-passport.git#6395dd9e5fdf1ecd48af5f02745a37a7aec9b9d0"
resolved "git://github.com/gunzip/spid-passport.git#5900adf925b99a91861b5d1f348ee8c7d499ed55"
dependencies:
passport "^0.4.0"
passport-saml "^0.33.0"
Expand Down

0 comments on commit 9c4d7da

Please sign in to comment.