From 481ad139cc023a3ba65e769f08f277368fa8a5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20BEAUFORT?= Date: Thu, 19 Jan 2017 20:16:41 +0100 Subject: [PATCH] Fix of issue 340 : Failed to submit to native print system with some RICOH printer when password is empty (#341) * Fix of issue 340 : Failed to submit to native print system with some RICOH printers when password is empty * Fix of issue 340 : Failed to submit to native print system with some RICOH printers when password is empty --- cups/translate-ticket.go | 6 +++++- cups/translate-ticket_test.go | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cups/translate-ticket.go b/cups/translate-ticket.go index 2e96b3b..8e37e08 100644 --- a/cups/translate-ticket.go +++ b/cups/translate-ticket.go @@ -31,8 +31,12 @@ func translateTicket(printer *lib.Printer, ticket *cdd.CloudJobTicket) (map[stri m := map[string]string{} for _, vti := range ticket.Print.VendorTicketItem { if vti.ID == ricohPasswordVendorID { + if vti.Value == "" { + // do not add specific map of options for Ricoh vendor like ppdLockedPrintPassword or ppdJobType when password is empty + continue; + } if !rRicohPasswordFormat.MatchString(vti.Value) { - return map[string]string{}, errors.New("Invalid password format") + return map[string]string{}, errors.New("Invalid password format") } } diff --git a/cups/translate-ticket_test.go b/cups/translate-ticket_test.go index aeac954..a9741db 100644 --- a/cups/translate-ticket_test.go +++ b/cups/translate-ticket_test.go @@ -281,10 +281,10 @@ func TestTranslateTicket_RicohLockedPrint(t *testing.T) { } expected = map[string]string{} o, err = translateTicket(&printer, &ticket) - if err == nil { - t.Log("expected error") + if err != nil { + t.Logf("did not expect error %s", err) t.Fail() - } + } if !reflect.DeepEqual(o, expected) { t.Logf("expected\n %+v\ngot\n %+v", expected, o) t.Fail()