Skip to content
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

Add support for embargo acknowledgement in python and golang backends #4485

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7946887
Add support for embargo acknowledgement in python backend
lukaszgryglicki Nov 21, 2024
1c0db12
Sync with AWS env updates
lukaszgryglicki Nov 27, 2024
247a9f8
ngrok details
lukaszgryglicki Nov 27, 2024
8e02cb1
Testing POST '/v1/signature' API
lukaszgryglicki Nov 27, 2024
3eeaf1f
WIP 'request_individual_signature' API
lukaszgryglicki Nov 27, 2024
c925764
Handle employee_signature
lukaszgryglicki Nov 27, 2024
e6df63d
Reorganized scripts/utils
lukaszgryglicki Nov 27, 2024
4f5ebf5
WIP golang API
lukaszgryglicki Nov 27, 2024
135774c
Update script
lukaszgryglicki Nov 27, 2024
823dbde
update golang API endpoint
lukaszgryglicki Nov 27, 2024
3370bda
Update util scripts
lukaszgryglicki Nov 29, 2024
e8cb5f0
Merge branch 'dev' into lukaszgryglicki-4482-add-embargo_acked-to-cla…
lukaszgryglicki Nov 29, 2024
f753f22
Run tests locally - added util script
lukaszgryglicki Nov 29, 2024
8f471ab
Merge branch 'dev' into lukaszgryglicki-4482-add-embargo_acked-to-cla…
lukaszgryglicki Dec 4, 2024
f2594aa
Update scripts
lukaszgryglicki Dec 4, 2024
1c67775
Handle py/go APIs
lukaszgryglicki Dec 4, 2024
ab386de
Updaste util script
lukaszgryglicki Dec 4, 2024
143221b
Add docusign envs
lukaszgryglicki Dec 4, 2024
359e54b
Example tests in comment
lukaszgryglicki Dec 4, 2024
ee55d19
Resolve merge conflicts
lukaszgryglicki Dec 4, 2024
73a1685
No longer needed
lukaszgryglicki Dec 4, 2024
d5388d5
Merge branch 'dev' into lukaszgryglicki-4482-add-embargo_acked-to-cla…
lukaszgryglicki Dec 4, 2024
3213897
Python APIs update to also set embargo_acked flag on existing signatu…
lukaszgryglicki Dec 5, 2024
22de891
Handle golang APIs signatures embargo acknowledgemet falgs
lukaszgryglicki Dec 5, 2024
32c9f1d
go fmt
lukaszgryglicki Dec 5, 2024
7aa75a8
Ready for review
lukaszgryglicki Dec 5, 2024
9442e3a
Ready for Review
lukaszgryglicki Dec 5, 2024
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: 2 additions & 0 deletions cla-backend-go/signatures/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (repo repository) buildProjectSignatureModels(ctx context.Context, results
SignatureReferenceNameLower: dbSignature.SignatureReferenceNameLower,
SignatureSigned: dbSignature.SignatureSigned,
SignatureApproved: dbSignature.SignatureApproved,
SignatureEmbargoAcked: dbSignature.SignatureEmbargoAcked,
SignatureDocumentMajorVersion: strconv.Itoa(dbSignature.SignatureDocumentMajorVersion),
SignatureDocumentMinorVersion: strconv.Itoa(dbSignature.SignatureDocumentMinorVersion),
Version: strconv.Itoa(dbSignature.SignatureDocumentMajorVersion) + "." + strconv.Itoa(dbSignature.SignatureDocumentMinorVersion),
Expand Down Expand Up @@ -237,6 +238,7 @@ func (repo repository) buildProjectSignatureSummaryModels(ctx context.Context, r
SignatureReferenceNameLower: dbSignature.SignatureReferenceNameLower,
SignatureSigned: dbSignature.SignatureSigned,
SignatureApproved: dbSignature.SignatureApproved,
SignatureEmbargoAcked: dbSignature.SignatureEmbargoAcked,
SignatureReferenceType: dbSignature.SignatureReferenceType,
ProjectID: dbSignature.SignatureProjectID,
SignedOn: dbSignature.SignedOn,
Expand Down
1 change: 1 addition & 0 deletions cla-backend-go/signatures/dbmodels.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ItemSignature struct {
DateModified string `json:"date_modified,omitempty"`
SignatureApproved bool `json:"signature_approved,omitempty"`
SignatureSigned bool `json:"signature_signed"`
SignatureEmbargoAcked bool `json:"signature_embargo_acked,omitempty"`
SignatureDocumentMajorVersion int `json:"signature_document_major_version,omitempty"`
SignatureDocumentMinorVersion int `json:"signature_document_minor_version,omitempty"`
SignatureSignURL string `json:"signature_sign_url,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions cla-backend-go/signatures/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type SignatureDynamoDB struct {
SignatureACL []string `json:"signature_acl"` // [github:1234567]
SignatureApproved bool `json:"signature_approved"` // true if the signature is approved, false if revoked/invalidated
SignatureSigned bool `json:"signature_signed"` // true if the signature has been signed
SignatureEmbargoAcked bool `json:"signature_embargo_acked"` // true if the signature's embargo was acknowledged
SignatureReferenceType string `json:"signature_reference_type"` // one of: user, company
SignatureReferenceName string `json:"signature_reference_name"` // John Doe
SignatureReferenceNameLower string `json:"signature_reference_name_lower"` // john doe
Expand Down
12 changes: 11 additions & 1 deletion cla-backend-go/signatures/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,11 @@ func (repo repository) ValidateProjectRecord(ctx context.Context, signatureID, n
expressionAttributeValues[":a"] = &dynamodb.AttributeValue{BOOL: aws.Bool(true)}
updateExpression = updateExpression + " #A = :a,"

// Set embago acknowledged flag
// expressionAttributeNames["#E"] = aws.String("signature_embargo_acked")
// expressionAttributeValues[":e"] = &dynamodb.AttributeValue{BOOL: aws.Bool(true)}
// updateExpression = updateExpression + " #E = :e,"

expressionAttributeNames["#S"] = aws.String("note")
expressionAttributeValues[":s"] = &dynamodb.AttributeValue{S: aws.String(note)}
updateExpression = updateExpression + " #S = :s"
Expand Down Expand Up @@ -2527,6 +2532,7 @@ func (repo repository) CreateProjectCompanyEmployeeSignature(ctx context.Context
SignatureReferenceID: employeeUserModel.UserID,
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureDocumentMajorVersion: 2,
SignatureDocumentMinorVersion: 0,
SigTypeSignedApprovedID: fmt.Sprintf("ecla#true#true#%s", companyModel.CompanyID),
Expand Down Expand Up @@ -4545,6 +4551,7 @@ func (repo repository) getIntermediateICLAResponse(f logrus.Fields, dbSignatures
LfUsername: sig.UserLFUsername,
SignatureApproved: sig.SignatureApproved,
SignatureSigned: sig.SignatureSigned,
SignatureEmbargoAcked: true,
SignatureModified: sig.DateModified,
SignatureID: sig.SignatureID,
SignedOn: sigSignedTime,
Expand Down Expand Up @@ -4928,7 +4935,10 @@ func (repo repository) ActivateSignature(ctx context.Context, signatureID string
}

// Build the expression
expressionUpdate := expression.Set(expression.Name("signature_approved"), expression.Value(true)).Set(expression.Name("signature_signed"), expression.Value(false))
expressionUpdate := expression.
Set(expression.Name("signature_approved"), expression.Value(true)).
Set(expression.Name("signature_signed"), expression.Value(false)).
Set(expression.Name("signature_embargo_acked"), expression.Value(true))

expr, err := expression.NewBuilder().WithUpdate(expressionUpdate).Build()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/corporate-signature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ properties:
description: the signature approved flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureReferenceType:
type: string
description: the signature reference type - either user or company
Expand Down
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/icla-signature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ properties:
description: the signature signed flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureModified:
type: string
description: the signature modified created time
Expand Down
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/signature-summary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ properties:
description: the signature approved flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureReferenceType:
type: string
description: the signature reference type - either user or company
Expand Down
5 changes: 5 additions & 0 deletions cla-backend-go/swagger/common/signature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ properties:
description: the signature approved flag - true or false value
example: true
x-omitempty: false
signatureEmbargoAcked:
type: boolean
description: the signature embargo acknowledged flag - true or false value
example: true
# x-omitempty: false
signatureReferenceType:
type: string
description: the signature reference type - either user or company
Expand Down
7 changes: 7 additions & 0 deletions cla-backend-go/v2/company/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-13T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
Expand All @@ -48,6 +49,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-15T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
Expand All @@ -57,6 +59,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-14T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
Expand All @@ -76,6 +79,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-13T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
Expand All @@ -85,6 +89,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-15T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
Expand All @@ -94,6 +99,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "2021-09-14T11:59:00.981612+0000",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id",
Expand All @@ -103,6 +109,7 @@ func TestGetCompanyProjectContributors(t *testing.T) {
SignatureCreated: "",
SignatureApproved: true,
SignatureSigned: true,
SignatureEmbargoAcked: true,
SignatureMajorVersion: "1",
SignatureMinorVersion: "0",
SignatureReferenceID: "signature_reference_id_empty",
Expand Down
1 change: 1 addition & 0 deletions cla-backend-go/v2/dynamo_events/cla_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (s *service) SetInitialCLAManagerACSPermissions(ctx context.Context, signat
f["projectID"] = sig.ProjectID
f["signed"] = sig.SignatureSigned
f["approved"] = sig.SignatureApproved
f["embargo_acked"] = sig.SignatureEmbargoAcked
f["companyName"] = sig.CompanyName
f["claType"] = sig.ClaType

Expand Down
3 changes: 3 additions & 0 deletions cla-backend-go/v2/dynamo_events/signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Signature struct {
DateModified string `json:"date_modified"`
SignatureApproved bool `json:"signature_approved"`
SignatureSigned bool `json:"signature_signed"`
SignatureEmbargoAcked bool `json:"signature_embargo_acked"`
SignatureDocumentMajorVersion string `json:"signature_document_major_version"`
SignatureDocumentMinorVersion string `json:"signature_document_minor_version"`
SignatureReferenceID string `json:"signature_reference_id"`
Expand Down Expand Up @@ -95,6 +96,7 @@ func (s *service) SignatureAssignContributorEvent(event events.DynamoDBEventReco
f["projectID"] = newSignature.SignatureProjectID
f["approved"] = newSignature.SignatureApproved
f["signed"] = newSignature.SignatureSigned
f["embargo_acked"] = newSignature.SignatureEmbargoAcked

if !oldSignature.SignatureSigned && newSignature.SignatureSigned {
log.WithFields(f).Debug("signature is now signed - assigning contributor...")
Expand Down Expand Up @@ -138,6 +140,7 @@ func (s *service) SignatureSignedEvent(event events.DynamoDBEventRecord) error {
f["projectID"] = newSignature.SignatureProjectID
f["approved"] = newSignature.SignatureApproved
f["signed"] = newSignature.SignatureSigned
f["embargo_acked"] = newSignature.SignatureEmbargoAcked

// check if signature signed event is received
if !oldSignature.SignatureSigned && newSignature.SignatureSigned {
Expand Down
16 changes: 13 additions & 3 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ func (s *service) SignedIndividualCallbackGithub(ctx context.Context, payload []
log.WithFields(f).Debugf("envelope signed - status: %s", status)
updates := map[string]interface{}{
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
"user_docusign_raw_xml": string(payload),
Expand Down Expand Up @@ -657,6 +658,7 @@ func (s *service) SignedIndividualCallbackGitlab(ctx context.Context, payload []
log.WithFields(f).Debugf("envelope signed - status: %s", status)
updates := map[string]interface{}{
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
"user_docusign_raw_xml": string(payload),
Expand Down Expand Up @@ -890,6 +892,7 @@ func (s *service) SignedIndividualCallbackGerrit(ctx context.Context, payload []
log.WithFields(f).Debugf("envelope signed - status: %s", status)
updates := map[string]interface{}{
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
"user_docusign_raw_xml": string(payload),
Expand Down Expand Up @@ -1138,9 +1141,10 @@ func (s *service) SignedCorporateCallback(ctx context.Context, payload []byte, c
if status == DocusignCompleted && !signature.SignatureSigned {
_, currentTime := utils.CurrentTime()
updates := map[string]interface{}{
"signature_signed": true,
"date_modified": currentTime,
"signed_on": currentTime,
"signature_signed": true,
"signature_embargo_acked": true,
"date_modified": currentTime,
"signed_on": currentTime,
}

userSignedDate := info.EnvelopeStatus.RecipientStatuses[0].Signed
Expand Down Expand Up @@ -1371,6 +1375,7 @@ func (s *service) RequestIndividualSignature(ctx context.Context, input *models.
SignatureProjectID: latestSignature.ProjectID,
SignatureApproved: latestSignature.SignatureApproved,
SignatureSigned: latestSignature.SignatureSigned,
SignatureEmbargoAcked: true,
SignatureReferenceName: latestSignature.SignatureReferenceName,
SignatureReferenceNameLower: latestSignature.SignatureReferenceNameLower,
SignedOn: latestSignature.SignedOn,
Expand Down Expand Up @@ -1443,6 +1448,7 @@ func (s *service) RequestIndividualSignature(ctx context.Context, input *models.
DateModified: currentTime,
SignatureSigned: false,
SignatureApproved: true,
SignatureEmbargoAcked: true,
SignatureDocumentMajorVersion: majorVersion,
SignatureDocumentMinorVersion: minorVersion,
SignatureReferenceID: *input.UserID,
Expand Down Expand Up @@ -2359,6 +2365,7 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
SignatureProjectID: latestSignature.ProjectID,
SignatureApproved: latestSignature.SignatureApproved,
SignatureSigned: latestSignature.SignatureSigned,
SignatureEmbargoAcked: true,
SignatureReferenceName: latestSignature.SignatureReferenceName,
SignatureReferenceNameLower: latestSignature.SignatureReferenceNameLower,
SignedOn: latestSignature.SignedOn,
Expand Down Expand Up @@ -2397,6 +2404,7 @@ func (s *service) RequestIndividualSignatureGerrit(ctx context.Context, input *m
SignatureReferenceType: utils.SignatureReferenceTypeUser,
SignatureSigned: false,
SignatureApproved: true,
SignatureEmbargoAcked: true,
SignatureType: utils.SignatureTypeCLA,
SignatureReferenceID: *input.UserID,
SignatureReturnURLType: input.ReturnURLType,
Expand Down Expand Up @@ -2571,6 +2579,7 @@ func (s *service) requestCorporateSignature(ctx context.Context, apiURL string,
SignatoryName: signatoryName,
SignatureSigned: companySignature.SignatureSigned,
SignatureApproved: companySignature.SignatureApproved,
SignatureEmbargoAcked: true,
DateCreated: companySignature.Created,
SignatureDocumentMajorVersion: majorVersion,
SignatureDocumentMinorVersion: minorVersion,
Expand Down Expand Up @@ -2611,6 +2620,7 @@ func (s *service) requestCorporateSignature(ctx context.Context, apiURL string,
SignatoryName: signatoryName,
SignatureSigned: false,
SignatureApproved: true,
SignatureEmbargoAcked: true,
SignatureCallbackURL: callbackURL,
SignatureReturnURL: input.ReturnURL,
SigtypeSignedApprovedID: fmt.Sprintf("%s#%v#%v#%s", utils.SignatureTypeCCLA, signed, approved, signatureID),
Expand Down
16 changes: 16 additions & 0 deletions cla-backend/cla/controllers/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def create_signature(signature_project_id, # pylint: disable=too-many-arguments
signature_type='cla',
signature_approved=False,
signature_signed=False,
signature_embargo_acked=True,
signature_return_url=None,
signature_sign_url=None,
signature_user_ccla_company_id=None,
Expand All @@ -74,6 +75,8 @@ def create_signature(signature_project_id, # pylint: disable=too-many-arguments
:type signature_signed: boolean
:param signature_approved: Whether or not the signature has been approved.
:type signature_approved: boolean
:param signature_embargo_acked: Whether or not the embargo was acknowledged
:type signature_embargo_acked: boolean
:param signature_return_url: The URL the user will be redirected to after signing.
:type signature_return_url: string
:param signature_sign_url: The URL the user must visit to sign the signature.
Expand Down Expand Up @@ -125,6 +128,7 @@ def create_signature(signature_project_id, # pylint: disable=too-many-arguments
signature.set_signature_type(signature_type)
signature.set_signature_signed(signature_signed)
signature.set_signature_approved(signature_approved)
signature.set_signature_embargo_acked(signature_embargo_acked)
signature.set_signature_return_url(signature_return_url)
signature.set_signature_sign_url(signature_sign_url)
if signature_user_ccla_company_id is not None:
Expand All @@ -151,6 +155,7 @@ def update_signature(signature_id, # pylint: disable=too-many-arguments,too-man
signature_type=None,
signature_approved=None,
signature_signed=None,
signature_embargo_acked=True,
signature_return_url=None,
signature_sign_url=None,
domain_whitelist=None,
Expand All @@ -177,6 +182,8 @@ def update_signature(signature_id, # pylint: disable=too-many-arguments,too-man
:type signature_signed: boolean | None
:param signature_approved: Whether this signature is approved or not.
:type signature_approved: boolean | None
:param signature_embargo_acked: Whether this signature's embargo is acknowledged
:type signature_embargo_acked: boolean | None
:param signature_return_url: The URL the user will be sent to after signing.
:type signature_return_url: string | None
:param signature_sign_url: The URL the user must visit to sign the signature.
Expand Down Expand Up @@ -238,6 +245,13 @@ def update_signature(signature_id, # pylint: disable=too-many-arguments,too-man
update_str += f'signature_approved updated to {val} \n'
except KeyError:
return {'errors': {'signature_approved': 'Invalid value passed in for true/false field'}}
if signature_embargo_acked is not None:
try:
val = hug.types.smart_boolean(signature_embargo_acked)
signature.set_signature_embargo_acked(val)
update_str += f'signature_embargo_acked updated to {val} \n'
except KeyError:
return {'errors': {'signature_embargo_acked': 'Invalid value passed in for true/false field'}}
if signature_return_url is not None:
try:
val = cla.hug_types.url(signature_return_url)
Expand Down Expand Up @@ -554,6 +568,8 @@ def create_bot_signature(bot_user: User, signature: Signature) -> Optional[Signa
bot_sig.set_signature_document_minor_version(signature.get_signature_document_minor_version())
bot_sig.set_signature_approved(True)
bot_sig.set_signature_signed(True)
# should bot signature by automaticaly set to "embargo acknowledged"?
bot_sig.set_signature_embargo_acked(True)
bot_sig.set_signature_type('cla')
bot_sig.set_signature_reference_type('user')
bot_sig.set_signature_user_ccla_company_id(bot_user.get_user_company_id())
Expand Down
Loading
Loading