@@ -101,7 +101,7 @@ func TestNewOrderRequest_Validate(t *testing.T) {
101
101
return test {
102
102
nor : & NewOrderRequest {
103
103
Identifiers : []acme.Identifier {
104
- {Type : "wireapp-id " , Value : "{}" },
104
+ {Type : "wireapp-device " , Value : "{}" },
105
105
},
106
106
},
107
107
err : acme .NewError (acme .ErrorMalformedType , `invalid Wire client ID "": invalid Wire client ID URI "": error parsing : scheme is missing` ),
@@ -111,7 +111,7 @@ func TestNewOrderRequest_Validate(t *testing.T) {
111
111
return test {
112
112
nor : & NewOrderRequest {
113
113
Identifiers : []acme.Identifier {
114
- {
Type :
"wireapp-id " ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "nowireapp://example.com", "handle": "wireapp://%[email protected] "}` },
114
+ {
Type :
"wireapp-device " ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "nowireapp://example.com", "handle": "wireapp://%[email protected] "}` },
115
115
},
116
116
},
117
117
err : acme .NewError (acme .ErrorMalformedType , `invalid Wire client ID "nowireapp://example.com": invalid Wire client ID scheme "nowireapp"; expected "wireapp"` ),
@@ -121,7 +121,7 @@ func TestNewOrderRequest_Validate(t *testing.T) {
121
121
return test {
122
122
nor : & NewOrderRequest {
123
123
Identifiers : []acme.Identifier {
124
- {
Type :
"wireapp-id " ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://[email protected] ", "handle": "wireapp://%[email protected] "}` },
124
+ {
Type :
"wireapp-device " ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://[email protected] ", "handle": "wireapp://%[email protected] "}` },
125
125
},
126
126
},
127
127
err :
acme .
NewError (
acme .
ErrorMalformedType ,
`invalid Wire client ID "wireapp://[email protected] ": invalid Wire client ID username "user-device"` ),
@@ -205,13 +205,28 @@ func TestNewOrderRequest_Validate(t *testing.T) {
205
205
naf : naf ,
206
206
}
207
207
},
208
- "ok/wireapp-idd " : func (t * testing.T ) test {
208
+ "ok/wireapp-user " : func (t * testing.T ) test {
209
209
nbf := time .Now ().UTC ().Add (time .Minute )
210
210
naf := time .Now ().UTC ().Add (5 * time .Minute )
211
211
return test {
212
212
nor : & NewOrderRequest {
213
213
Identifiers : []acme.Identifier {
214
- {
Type :
"wireapp-id" ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://[email protected] ", "handle": "wireapp://%[email protected] "}` },
214
+ {
Type :
"wireapp-user" ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "handle": "wireapp://%[email protected] "}` },
215
+ },
216
+ NotAfter : naf ,
217
+ NotBefore : nbf ,
218
+ },
219
+ nbf : nbf ,
220
+ naf : naf ,
221
+ }
222
+ },
223
+ "ok/wireapp-device" : func (t * testing.T ) test {
224
+ nbf := time .Now ().UTC ().Add (time .Minute )
225
+ naf := time .Now ().UTC ().Add (5 * time .Minute )
226
+ return test {
227
+ nor : & NewOrderRequest {
228
+ Identifiers : []acme.Identifier {
229
+ {
Type :
"wireapp-device" ,
Value :
`{"name": "Smith, Alice M (QA)", "domain": "example.com", "client-id": "wireapp://[email protected] ", "handle": "wireapp://%[email protected] "}` },
215
230
},
216
231
NotAfter : naf ,
217
232
NotBefore : nbf ,
@@ -1719,7 +1734,7 @@ MCowBQYDK2VwAyEA5c+4NKZSNQcR1T8qN6SjwgdPZQ0Ge12Ylx/YeGAJ35k=
1719
1734
},
1720
1735
}
1721
1736
},
1722
- "ok/default-naf-nbf-wireapp" : func (t * testing.T ) test {
1737
+ "ok/default-naf-nbf-wireapp-user " : func (t * testing.T ) test {
1723
1738
acmeWireProv := newWireProvisionerWithOptions (t , & provisioner.Options {
1724
1739
Wire : & wire.Options {
1725
1740
OIDC : & wire.OIDCOptions {
@@ -1749,7 +1764,7 @@ MCowBQYDK2VwAyEA5c+4NKZSNQcR1T8qN6SjwgdPZQ0Ge12Ylx/YeGAJ35k=
1749
1764
acc := & acme.Account {ID : "accID" }
1750
1765
nor := & NewOrderRequest {
1751
1766
Identifiers : []acme.Identifier {
1752
- {Type : "wireapp-id " , Value : `{"client-id ": "wireapp://user!client@domain "}` },
1767
+ {
Type :
"wireapp-user " ,
Value :
`{"name ": "Alice Smith", "handle": " wireapp://%[email protected] "}` },
1753
1768
},
1754
1769
}
1755
1770
b , err := json .Marshal (nor )
@@ -1758,9 +1773,8 @@ MCowBQYDK2VwAyEA5c+4NKZSNQcR1T8qN6SjwgdPZQ0Ge12Ylx/YeGAJ35k=
1758
1773
ctx = context .WithValue (ctx , accContextKey , acc )
1759
1774
ctx = context .WithValue (ctx , payloadContextKey , & payloadInfo {value : b })
1760
1775
var (
1761
- ch1 , ch2 * * acme.Challenge
1762
- az1ID * string
1763
- count = 0
1776
+ ch1 * * acme.Challenge
1777
+ az1ID * string
1764
1778
)
1765
1779
return test {
1766
1780
ctx : ctx ,
@@ -1769,20 +1783,113 @@ MCowBQYDK2VwAyEA5c+4NKZSNQcR1T8qN6SjwgdPZQ0Ge12Ylx/YeGAJ35k=
1769
1783
ca : & mockCA {},
1770
1784
db : & acme.MockDB {
1771
1785
MockCreateChallenge : func (ctx context.Context , ch * acme.Challenge ) error {
1772
- switch count {
1773
- case 0 :
1774
- ch .ID = "wireapp-oidc"
1775
- assert .Equals (t , ch .Type , acme .WIREOIDC01 )
1776
- ch1 = & ch
1777
- case 1 :
1778
- ch .ID = "wireapp-dpop"
1779
- assert .Equals (t , ch .Type , acme .WIREDPOP01 )
1780
- ch2 = & ch
1781
- default :
1782
- assert .FatalError (t , errors .New ("test logic error" ))
1783
- return errors .New ("force" )
1784
- }
1785
- count ++
1786
+ ch .ID = "wireapp-oidc"
1787
+ assert .Equals (t , ch .Type , acme .WIREOIDC01 )
1788
+ ch1 = & ch
1789
+ assert .Equals (t , ch .AccountID , "accID" )
1790
+ assert .NotEquals (t , ch .Token , "" )
1791
+ assert .Equals (t , ch .Status , acme .StatusPending )
1792
+ assert .
Equals (
t ,
ch .
Value ,
`{"name": "Alice Smith", "handle": "wireapp://%[email protected] "}` )
1793
+ return nil
1794
+ },
1795
+ MockCreateAuthorization : func (ctx context.Context , az * acme.Authorization ) error {
1796
+ az .ID = "az1ID"
1797
+ az1ID = & az .ID
1798
+ assert .Equals (t , az .AccountID , "accID" )
1799
+ assert .NotEquals (t , az .Token , "" )
1800
+ assert .Equals (t , az .Status , acme .StatusPending )
1801
+ assert .Equals (t , az .Identifier , nor .Identifiers [0 ])
1802
+ assert .Equals (t , az .Challenges , []* acme.Challenge {* ch1 })
1803
+ assert .Equals (t , az .Wildcard , false )
1804
+ return nil
1805
+ },
1806
+ MockCreateOrder : func (ctx context.Context , o * acme.Order ) error {
1807
+ o .ID = "ordID"
1808
+ assert .Equals (t , o .AccountID , "accID" )
1809
+ assert .Equals (t , o .ProvisionerID , prov .GetID ())
1810
+ assert .Equals (t , o .Status , acme .StatusPending )
1811
+ assert .Equals (t , o .Identifiers , nor .Identifiers )
1812
+ assert .Equals (t , o .AuthorizationIDs , []string {* az1ID })
1813
+ return nil
1814
+ },
1815
+ MockGetExternalAccountKeyByAccountID : func (ctx context.Context , provisionerID , accountID string ) (* acme.ExternalAccountKey , error ) {
1816
+ assert .Equals (t , prov .GetID (), provisionerID )
1817
+ assert .Equals (t , "accID" , accountID )
1818
+ return nil , nil
1819
+ },
1820
+ },
1821
+ vr : func (t * testing.T , o * acme.Order ) {
1822
+ now := clock .Now ()
1823
+ testBufferDur := 5 * time .Second
1824
+ orderExpiry := now .Add (defaultOrderExpiry )
1825
+ expNbf := now .Add (- defaultOrderBackdate )
1826
+ expNaf := now .Add (prov .DefaultTLSCertDuration ())
1827
+
1828
+ assert .Equals (t , o .ID , "ordID" )
1829
+ assert .Equals (t , o .Status , acme .StatusPending )
1830
+ assert .Equals (t , o .Identifiers , nor .Identifiers )
1831
+ assert .Equals (t , o .AuthorizationURLs , []string {fmt .Sprintf ("%s/acme/%s/authz/az1ID" , baseURL .String (), escProvName )})
1832
+ assert .True (t , o .NotBefore .Add (- testBufferDur ).Before (expNbf ))
1833
+ assert .True (t , o .NotBefore .Add (testBufferDur ).After (expNbf ))
1834
+ assert .True (t , o .NotAfter .Add (- testBufferDur ).Before (expNaf ))
1835
+ assert .True (t , o .NotAfter .Add (testBufferDur ).After (expNaf ))
1836
+ assert .True (t , o .ExpiresAt .Add (- testBufferDur ).Before (orderExpiry ))
1837
+ assert .True (t , o .ExpiresAt .Add (testBufferDur ).After (orderExpiry ))
1838
+ },
1839
+ }
1840
+ },
1841
+ "ok/default-naf-nbf-wireapp-device" : func (t * testing.T ) test {
1842
+ acmeWireProv := newWireProvisionerWithOptions (t , & provisioner.Options {
1843
+ Wire : & wire.Options {
1844
+ OIDC : & wire.OIDCOptions {
1845
+ Provider : & wire.Provider {
1846
+ IssuerURL : "https://issuer.example.com" ,
1847
+ AuthURL : "" ,
1848
+ TokenURL : "" ,
1849
+ JWKSURL : "" ,
1850
+ UserInfoURL : "" ,
1851
+ Algorithms : []string {"ES256" },
1852
+ },
1853
+ Config : & wire.Config {
1854
+ ClientID : "integration test" ,
1855
+ SignatureAlgorithms : []string {"ES256" },
1856
+ SkipClientIDCheck : true ,
1857
+ SkipExpiryCheck : true ,
1858
+ SkipIssuerCheck : true ,
1859
+ InsecureSkipSignatureCheck : true ,
1860
+ Now : time .Now ,
1861
+ },
1862
+ },
1863
+ DPOP : & wire.DPOPOptions {
1864
+ SigningKey : []byte (fakeWireSigningKey ),
1865
+ },
1866
+ },
1867
+ })
1868
+ acc := & acme.Account {ID : "accID" }
1869
+ nor := & NewOrderRequest {
1870
+ Identifiers : []acme.Identifier {
1871
+ {Type : "wireapp-device" , Value : `{"client-id": "wireapp://user!client@domain"}` },
1872
+ },
1873
+ }
1874
+ b , err := json .Marshal (nor )
1875
+ assert .FatalError (t , err )
1876
+ ctx := acme .NewProvisionerContext (context .Background (), acmeWireProv )
1877
+ ctx = context .WithValue (ctx , accContextKey , acc )
1878
+ ctx = context .WithValue (ctx , payloadContextKey , & payloadInfo {value : b })
1879
+ var (
1880
+ ch1 * * acme.Challenge
1881
+ az1ID * string
1882
+ )
1883
+ return test {
1884
+ ctx : ctx ,
1885
+ statusCode : 201 ,
1886
+ nor : nor ,
1887
+ ca : & mockCA {},
1888
+ db : & acme.MockDB {
1889
+ MockCreateChallenge : func (ctx context.Context , ch * acme.Challenge ) error {
1890
+ ch .ID = "wireapp-dpop"
1891
+ assert .Equals (t , ch .Type , acme .WIREDPOP01 )
1892
+ ch1 = & ch
1786
1893
assert .Equals (t , ch .AccountID , "accID" )
1787
1894
assert .NotEquals (t , ch .Token , "" )
1788
1895
assert .Equals (t , ch .Status , acme .StatusPending )
@@ -1796,7 +1903,7 @@ MCowBQYDK2VwAyEA5c+4NKZSNQcR1T8qN6SjwgdPZQ0Ge12Ylx/YeGAJ35k=
1796
1903
assert .NotEquals (t , az .Token , "" )
1797
1904
assert .Equals (t , az .Status , acme .StatusPending )
1798
1905
assert .Equals (t , az .Identifier , nor .Identifiers [0 ])
1799
- assert .Equals (t , az .Challenges , []* acme.Challenge {* ch1 , * ch2 })
1906
+ assert .Equals (t , az .Challenges , []* acme.Challenge {* ch1 })
1800
1907
assert .Equals (t , az .Wildcard , false )
1801
1908
return nil
1802
1909
},
0 commit comments