/* Ċ Ġ* ĠCopyright Ġ 2 0 2 1 - Present ĠOk ta , ĠInc . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . ok ta . idx . android Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . action . View Actions . replace Text Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers . is Displayed Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Text Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . ok ta . idx . android . infrastructure . CODE _ EDIT _ TEXT Ċ import Ġcom . ok ta . idx . android . infrastructure . CON FI R MED _ PASSWORD _ EDIT _ TEXT Ċ import Ġcom . ok ta . idx . android . infrastructure . ERROR _ TEXT _ VIEW Ċ import Ġcom . ok ta . idx . android . infrastructure . ID _ TOKEN _ TYPE _ TEXT _ VIEW Ċ import Ġcom . ok ta . idx . android . infrastructure . SELECT _ BUTTON Ċ import Ġcom . ok ta . idx . android . infrastructure . espress o . select Authenticator Ċ import Ġcom . ok ta . idx . android . infrastructure . espress o . waitFor Element Ċ import Ġcom . ok ta . idx . android . infrastructure . network . test Body FromFile Ċ import Ġcom . ok ta . idx . android . network . mock . Request Matchers . body With Json Path Ċ import Ġcom . ok ta . idx . android . network . mock . Request Matchers . path Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠSelf Service Password Recovery Test Ġ: ĠBase MainActivity Test () Ġ{ ĊĠĠĠ Ġ// ĠM ary Ġresets Ġher Ġpassword ĊĠĠĠ Ġ@ Test Ġfun Ġscenario _ 3 _ 1 _ 1 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Prefix Ġ= Ġ" scenario _ 3 _ 1 _ 1 " ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" oauth 2 / default / v 1 / interact ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / interact . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / int rospect ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / int rospect . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / recover ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / recover . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / identify ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / identify . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / challenge ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / challenge . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpath (" idp / idx / challenge / answer "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbody With Json Path ("/ credentials / pass code ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit . text Value (). equals (" 1 2 3 4 5 6 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / answer Email Code . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpath (" idp / idx / challenge / answer "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbody With Json Path ("/ credentials / pass code ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit . text Value (). equals (" abc 1 2 3 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / answer New Password . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" oauth 2 / v 1 / token ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / tokens . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" oauth 2 / default / v 1 / userinfo ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / userinfo . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġgo To Login () ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . forgot _ password _ button )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . username _ edit _ text )). perform ( replace Text (" M ary @ example . com ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . forgot _ password _ button )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ ĠwaitFor Element ( SELECT _ BUTTON ) ĊĠĠĠĠĠĠĠ Ġselect Authenticator (" Email ") ĊĊĠĠĠĠĠĠĠ ĠwaitFor Element ( CODE _ EDIT _ TEXT ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . code _ edit _ text )). perform ( replace Text (" 1 2 3 4 5 6 ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . submit _ button )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ ĠwaitFor Element ( CON FI R MED _ PASSWORD _ EDIT _ TEXT ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . password _ edit _ text )). perform ( replace Text (" abc 1 2 3 ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . confirmed _ password _ edit _ text )). perform ( replace Text (" abc 1 2 3 ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . submit _ button )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ ĠwaitFor Element ( ID _ TOKEN _ TYPE _ TEXT _ VIEW ) ĊĠĠĠĠĠĠĠ Ġon View ( with Text (" Token ĠType :" )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Text (" Bearer ")). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠM ary Ġtries Ġto Ġreset Ġa Ġpassword Ġwith Ġthe Ġwrong Ġemail ĊĠĠĠ Ġ@ Test Ġfun Ġscenario _ 3 _ 1 _ 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Prefix Ġ= Ġ" scenario _ 3 _ 1 _ 2 " ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" oauth 2 / default / v 1 / interact ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / interact . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / int rospect ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / int rospect . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / recover ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / recover . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġnetwork Rule . enqueue ( path (" idp / idx / identify ")) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponse . test Body FromFile ("$ mock Prefix / identify . json ") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġgo To Login () ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . forgot _ password _ button )). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . username _ edit _ text )). perform ( replace Text (" M ary @ unknown . com ")) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . forgot _ password _ button )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ ĠwaitFor Element ( ERROR _ TEXT _ VIEW ) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . error _ text _ view )). check ( matches ( with Text (" There Ġis Ġno Ġaccount Ġwith Ġthe ĠUsername ĠM ary @ unknown . com . "))) ĊĠĠĠ Ġ} Ċ } Ċ